Django啟動(dòng)時(shí)找不到mysqlclient問題解決方案
在使用Django2.0 并配置了mysql作為數(shù)據(jù)庫時(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í)行如下命令即可
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Mysql故障排除:Starting MySQL. ERROR! Manager of pid-file quit without updating file2. MySQL插入數(shù)據(jù)時(shí),如果記錄不存在則insert,如果存在則update3. oracle觸發(fā)器介紹4. Mysql入門系列:建立MYSQL客戶機(jī)程序的一般過程5. 巧用SQL語言在ACCESS數(shù)據(jù)庫中批量替換內(nèi)容6. Mysql入門系列:在MYSQL結(jié)果集上執(zhí)行計(jì)算7. MySQL創(chuàng)始人發(fā)郵件尋求中國幫助8. MySQL存儲(chǔ)引擎選擇InnoDB還是MyISAM9. 學(xué)好Oracle的六條總結(jié)10. MYSQL技巧:為現(xiàn)有字段添加自增屬性

網(wǎng)公網(wǎng)安備