使用Django2.0进行开发是出现如上错误,具体如下:
Traceback (most recent call last):
File "/home/san/PycharmProjects/MapleMooc/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
The above exception was the direct cause of the following exception:
...
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
解决方案:
init.py文件里添加两行代码:
import pymysql
pymysql.install_as_MySQLdb()
网友评论