Django啟動(dòng)時(shí)找不到mysqlclient問(wèn)題解決方案
在使用Django2.0 并配置了mysql作為數(shù)據(jù)庫(kù)時(shí),啟動(dòng)報(bào)錯(cuò):
報(bào)錯(cuò)1:找不到mysqlclient
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
解決方法
項(xiàng)目(settings.py同級(jí))目錄中__init__.py中添加
import pymysqlpymysql.install_as_MySQLdb()
報(bào)錯(cuò)2:版本檢查出錯(cuò)
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.
解決方法:
找到Python安裝路勁下的/Users/MAC/env/MxShop/lib/python3.6/site-packages/django/db/backends/mysql/base.py文件
將文件中的如下代碼注釋
#if version < (1, 3, 3):# raise ImproperlyConfigured('mysqlclient 1.3.3 or newer is required; you have %s' % Database.__version__)
重新在項(xiàng)目manage.py路勁下執(zhí)行如下命令即可
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 如何遠(yuǎn)程調(diào)用ACCESS數(shù)據(jù)庫(kù)2. MySQL數(shù)據(jù)庫(kù)字符集修改中文UTF8(永久修改)3. ADODB連接access是出現(xiàn) 80004005 錯(cuò)誤的解決方法4. SQL Server 2022 AlwaysOn新特性之包含可用性組詳解5. Delphi中的Access技巧集6. 應(yīng)用經(jīng)驗(yàn):關(guān)于IBM DB2數(shù)據(jù)庫(kù)的注意事項(xiàng)7. IBM DB2 的數(shù)據(jù)復(fù)制、遷移方法8. 使用SQL語(yǔ)句創(chuàng)建觸發(fā)器的實(shí)例9. MySQL多表聯(lián)查的實(shí)現(xiàn)思路10. Mysql故障排除:Starting MySQL. ERROR! Manager of pid-file quit without updating file
