Django Error:No module named '*******'
(Disclaimer: This tutorial is for my learning to use, if a person using the technology has nothing to do with breaking the law himself)
(if there is an error, also wish to point out common progress .)
Error:No module named ‘MySQLdb’
Django_python2 connect to the database environment needs MysqlDB module, MysqlDB not a third-party library, needs to be initialized in Django.
The reason: MySqlDB is created from the __init__.py file pymysql in the install_as_MySQLdb () method.
# Django第三方库中初始化
# 找到python环境,.\Lib\site-packages\django\db\backends\mysql\__init__.py,添加以下代码
import pymysql
pymysql.install_as_MySQLdb()
# 如果没有pymysql模块, pip install pymysql
Error:No module named ‘×××’
Possible reason: no recognition to the path environment
# 在错误的根地址添加
import sys
sys.path.append('你python的site-packages的绝对路径')