标签:class cal lib opera tor named sql roo 解决
import MySQLdb as Database ModuleNotFoundError: No module named ‘MySQLdb‘
[root@bbs s12bbs]# python3 manage.py --help
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 25, in <module>
import MySQLdb as Database
ImportError: No module named ‘MySQLdb‘
vim /usr/lib/python3.4/site-packages/django/db/backends/mysql/base.py
#导入
#在from django.utils.safestring import SafeBytest,SafeTest下添加下面两条
import pymysql
pymysql.install_as_MySQLdb()
MySQLdb只支持Python2.,还不支持3.
可以用PyMySQL代替。安装方法:
pip install PyMySQL
然后在需要的项目中,把 init.py中添加两行:
import pymysql
pymysql.install_as_MySQLdb()
就可以用 import MySQLdb了。其他的方法与MySQLdb一样。
python3.*报“ImportError: No module named ‘MySQLdb'”
标签:class cal lib opera tor named sql roo 解决
原文地址:https://www.cnblogs.com/du-jun/p/13354218.html