1. 程式人生 > 實用技巧 >(資料遷移老問題)django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2

(資料遷移老問題)django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2

I、將你的Django降低到2.14以下即可:這個不用想,就要用最新的

II、升級的mysql客戶端版本至更高:電腦同時執行的還有php等其他語言,懶得折騰

III、按照以下步驟修改程式碼:

修復原始碼
按照文中配置,報錯django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
原因:django2.2和pymysql版本不匹配。mysqldb不支援python3.

# 解決辦法:
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)    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