安装报错类型,解决方案;
1. 数据库连接报错
MysqLdb只支持python2,pyMysqL支持3,都是使用c写的驱动,性能更好
# django中修改配置文件setting.py添加如下代码: import pyMysqL pyMysqL.install_as_MysqLdb()
解决方案:
raise ImproperlyConfigured('MysqLclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: MysqLclient 1.3.13 or newer is required; you have 0.9.3.
解决方案:
# "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/MysqL/base.py",line 36,in <module> # if version < (1,3,13): # raise ImproperlyConfigured('MysqLclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/MysqL/operations.py",line 146,in last_executed_query
query = query.decode(errors='replace')
解决方案: ==暂时使用第二种类型==
修改decode为encode
把条件注释掉,防止出现不可预知的错误,这个错误很可能是python2中类型str和unicode的原因,python3中只有unicode类型数据
# "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/MysqL/operations.py",line 146 # if query is not None: #query = query.encode(errors='replace')
解决完成之后完美运行