mysqlclient 1.3.13 or newer is required

Django開發,由sqlite3切換爲mysql
已經僞裝過了, 遷移時,報錯:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解決辦法:

  1. 將Django降低到2.14以下即可。(沒試過)
    II、升級mysql客戶端版本至更高。(沒試過)
    III、按照以下步驟修改代碼。 (親測有效)
    mysqlclient 1.3.13 or newer is required

按圖找到你Django目錄下的base.py文件
註釋掉下面2句:

if version < (1, 3, 13):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)

然後再進行數據庫遷移操作。

如果還有問題,比如出現了以下問題:
File "D:\Program Files\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'

那就打開上圖中的operations.py文件,146行中的decode改爲encode即可。

然後再次遷移,成功!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章