在setting.py同级目录下的__init__.py文件中加入以下代码 import pymysql pymysql.install_as_MySQLdb() 注意:pymysql的安装版本必须在0.7以上