关于Django报错“Did you install mysqlclient or MySQL-python?”的解决办法(前提:mysqlclient&MySQL都已经安装)

环境说明:
win10 专业版
python 2.7.16
django 1.11.9

遇到的问题:
python的库中已经安装了mysqlclient&MySQL两个库,debug的时候还是报错:

No module named MySQLdb.
Did you install mysqlclient or MySQL-python?

解决方案:
在django项目的根目录下的setting.py中添加如下两行代码:

import pymysql
pymysql.install_as_MySQLdb()  

重新debug项目就可以正常使用了

耶巴蒂!莱维贝贝

发布了101 篇原创文章 · 获赞 69 · 访问量 22万+

猜你喜欢

转载自blog.csdn.net/weekdawn/article/details/96474865