标签:pack mysq configure usr 3.x conf for 解决办法 适用于
报错如下:
File "/usr/local/python3/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 27, in <module>
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named ‘MySQLdb‘
MySQLdb 只适用于python2.x,。在python3.x的替代品是: import pymysql
解决办法:
vi /usr/local/python3/lib/python3.4/site-packages/django/db/backends/mysql/__init__.py
base.py 文件新增如下两行:
import pymysql
pymysql.install_as_MySQLdb()
如果还报如下错误:
AttributeError: module ‘pymysql‘ has no attribute ‘install_as_MySQLdb‘
解决方法:
pip uninstall PyMySQL3
pip install -U --force-reinstall pymysql
Django 错误之 No module named ‘MySQLdb’
标签:pack mysq configure usr 3.x conf for 解决办法 适用于
原文地址:https://www.cnblogs.com/liang545621/p/10233857.html