Django链接MySQL出错

错误一:No module named 'MySQLdb'python

缘由:python3链接MySQL不能再使用mysqldb,取而代之的是pymysql。mysql

解决方法:在python的MySQL包中,即路径:C:\Users\adong\AppData\Local\Programs\Python\Python36\Lib\site-packages\Django-2.0.3-py3.6.egg\django\db\backends\mysqlsql

下的__init__.py文件中加入:django

import pymysqlui

pymysql.install_as_MySQLdb()spa

 

错误二:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.Noneit

缘由:在解决了错误一之后出现了此错误。io

解决方法:在python的MySQL包中,即路径:C:\Users\adong\AppData\Local\Programs\Python\Python36\Lib\site-packages\Django-2.0.3-py3.6.egg\django\db\backends\mysqlclass

下的 base.py 文件中,注释掉一下两行代码:import

if version < (1, 3, 3):
     raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__) 

相关文章
相关标签/搜索