django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2
django2.2不支持pyMySQL,但2.2是LTS,有想过试试mysqldb,但是MySQLDB又不支持python3。。。。运行后,先后出现两次报错,的确让人头大。
今天在使用python3.7+django2.2+pymysql时遇到这个错误,
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2
别急,这主要是django2.2内部的一个版本限制在作怪
处理方案:
1.修复源码
按照文中配置,报错django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
原因:django2.2和pymysql版本不匹配。mysqldb不支持python3.
解决办法:找到python安装目录下的site-packages/django/db/backends/mysql
例如我的win下
C:\Python37\Lib\site-packages\django\db\backends\mysql(python安装目录)
第一步:打开base.py,先注释掉以下内容:
if version < (1, 3, 13): raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.’ % Database.version)
第二步,修改operations.py的第146行的decode修改为encode:
启动应用出现报错信息:File “C:\Python37\lib\site-packages\django\db\backends\mysql\operations.py”, line 146, in last_executed_query
query = query.decode(errors=‘replace’)
AttributeError: ‘str’ object has no attribute ‘decode’
解决办法:
打开此文件把146行的decode修改为encode,如下所示:
query = query.decode(errors='replace')
改成:
query = query.encode(errors='replace')
英语翻译My first objection is that politicians,even c 英语 2020-04-05 …
英语翻译FirstofallthecommentsinCAPSfromClintIforwarde 英语 2020-04-26 …
英语长难句分析33.Thereare,ofcourse,exceptions.Small--min 英语 2020-05-13 …
you know when you give you love you know when you 英语 2020-05-16 …
倒装句的类型 请帮忙分析下这几个句子是属于哪种情况下的倒装 倒装部分是?There are som 英语 2020-05-17 …
英语翻译【Lovely you 】Tell me I am a part of you Into 其他 2020-05-17 …
英语翻译1)A.AgooduniversityBScdegree(理科学士学位)withgoodgr 英语 2020-11-06 …
Ourmoodmaychangesuddenlylikeastormwithlightningand 英语 2020-11-28 …
django.core.exceptions.ImproperlyConfigured: mysql 0 2022-02-11 …
python3-Django运行报错TypeError: a bytes-like object i 0 2023-05-06 …