Django啟動時找不到mysqlclient問題解決方案
在使用Django2.0 并配置了mysql作為數(shù)據(jù)庫時,啟動報錯:
報錯1:找不到mysqlclient
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
解決方法
項目(settings.py同級)目錄中__init__.py中添加
import pymysqlpymysql.install_as_MySQLdb()
報錯2:版本檢查出錯
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__)
重新在項目manage.py路勁下執(zhí)行如下命令即可
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Mysql InnoDB的鎖定機制實例詳解2. MySQL中InnoDB和MyISAM類型的差別3. 恢復(fù)誤刪數(shù)據(jù)(SQL Server 2000)--Log Explorer4. Windows下在DOS用mysql命令行導(dǎo)入.sql文件5. MySQL 常用的拼接語句匯總6. MySQL插入數(shù)據(jù)時,如果記錄不存在則insert,如果存在則update7. 淺談Mysql連接數(shù)據(jù)庫時host和user的匹配規(guī)則8. SQL Server補丁版本的檢查和安裝過程中常見問題9. Mysql實現(xiàn)主從配置和多主多從配置10. 全面解讀MySQL主從復(fù)制,從原理到安裝配置
