Environment:
Ubuntu18.04
mysql:8.0
python: 3.6.8
django: 2.2.6
pymysql: 0.9.3
Install pymysql
pip install pymysql
introduce pymysql into Django
under the package with the same name as the project directory__init__. Write the following code to the PY file:
import pymysql
pymysql.install_as_MySQLdb()
configure MySQL in Django, and then start Django service. The errors are as follows:
File "/home/www/.local/share/virtualenvs/EduScore-UXZMOCwv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
Solution:
Use vim to open /home/www/.local/share/virtualenvs/EduScore-UXZMOCwv/lib/python3.6/site-packages/django/db/backends/mysql/base.py
file, and Comment out the following code
#if version < (1, 3, 13):
# raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
start Django server and find or report an error. The error information is:
AttributeError: 'str' object has no attribute 'decode'
Solution:
find the corresponding file and change the decode of the error line to encode
Similar Posts:
- django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named ‘M…
- [Solved] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
- [Solved] Error when connecting to MySQL when creating Django project
- [Solved] peewee error: ImportError: No module named ‘MySQLdb’;pymysql error: from . import connections # noqa: E402
- [Solved] Djiango Create Migrations Error: query = query.decode(errors=’replace’) AttributeError: ‘str’ object has no attribute ‘decode’
- Gunicorn starts with an error gunicorn.errors.haltserver
- How to Solve Django Error: No module named ‘MySQLdb’
- Python AttributeError: ‘unicode’ object has no attribute ‘tzinfo’
- [Solved] Django Error: Did you install mysqlclient?
- Django Run Error: RuntimeError: maximum recursion depth exceeded while calling a Python object