1. 程式人生 > >django 報錯:No module named 'MySQLdb'

django 報錯:No module named 'MySQLdb'

當你執行django時報如下錯誤:

'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
Did you install mysqlclient or MySQL-python?
 

原因:在專案的__init__檔案下缺少如下命令:

import pymysql

pymysql.install_as_MySQLdb()