报错环境 python=3.6.5,django=2.2,PyMySQL=0.9.3
……
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
Solution:
Django using MySQLdb drive when connected to MySQL by default, but does not support MySQLdb Python3, so here the MySQL driver set pymysql, use pip install pymysql installation, and then add the following code to __init__.py file in the project.
# Installation pymysql
pip install pymysql
#__init__.py
import pymysql
pymysql.install_as_MySQLdb()
The first:
Django 2.1.4 version drops on OK
The second (still using django 2.2 version):
First try to delete hidden files ".idea"
# Find Python environment django package, and into mysql file in the folder backends
cd /opt/anaconda3/envs/envAGC_Mini/lib/python3.6/site-packages/django/db/backends/mysql
# File listed below
# Base.py find the file, comment out base.py in the following section (lines 35/36)
if version < (1, 3, 3):
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
At this point still being given, the following error message:
AttributeError: ‘str’ object has no attribute ‘decode’
# Find operations.py file (146 lines), will be changed to encode decode
#linux vim to find shortcuts:? decode
if query is not None:
query = query.decode(errors=‘replace‘)
return query
# Changed
if query is not None:
query = query.encode(errors=‘replace‘)
return query
Add WeChat understand 27 great courses within the educational system of the Group