Tracking source code:
Problem file:Python36\lib\site-packages\django\db\backends\mysql\base.py
def get_new_connection(self, conn_params): conn = Database. connect(** conn_params) conn.encoders[SafeText] = conn.encoders[six.text_type] conn.encoders[SafeBytes] = conn.encoders[bytes] return conn
solution
- Downgrade MySQLclient. Uninstall first, then install the specified version.
pip3 uninstall mysqlclient
,pip3 install mysqlclient==1.3
. - My initial solution was to change the django code ( Python36\lib\site-packages\django\db\backends\mysql\base.py ), add an “if” as below:
def get_new_connection(self, conn_params): conn = Database. connect(** conn_params) conn.encoders[SafeText] = conn.encoders[six.text_type] #First determine whether the bytes exist in the encoder, and if so, perform the operation if bytes in conn.encoders: conn.encoders[SafeBytes] = conn.encoders[bytes] return conn
Read More:
- [Solved] Django backend processing Base64 file upload error
- Django uses Mysql to report an error loading MySQL DB module: no module named ‘mysqldb’
- [Solved] Django project locally Open Error: importerror: couldn’t import Django
- [Solved] raise KeyError(key) from err KeyError: ‘Dates‘
- [Solved] Python Django error: error: (1146, “Table ‘mydb.django_session’ doesn’t exist”)
- [Solved] Django Error: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
- [Solved] supervisor Error: /usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
- Python: Django exception when executing migrate operation: django.db.utils.OperationalError: (1051, “Unknown table’xxx’”)
- [Solved] Django Configurate celery error: django.db.utils.DatabaseError
- [Solved] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclie
- odoo Error: KeyError:‘ir.http‘ [How to Solve]
- numpy.concatenate() 253rd; 38169Keyerror: 0 [How to Solve]
- Django Issues: TypeError: “Settings” object is irreversible
- How to Solve Automatic error keyerror:***‘
- Python quote error: * * * keyerror: u ‘\ uxx’ [How to Solve]
- Error in sitecustomize set PYTHONVERBOSE for traceback KeyError: ‘PYTHONPATH’
- Pip3 install Mysqlclient Error: Command “python setup.py egg_info“ failed with error
- [Solved] Django.core.exceptions.ImproperlyConfigured: SQLite 3.9.0 or later is required (found 3.7.17).
- [Solved] PyTorch Lightning Error: KeyError: ‘hidden_states‘
- [Solved] flash initializate database error: Keyerror: ‘migrate’