搭建Django2.2+Python3+MySQL时新建app时报错

  1. 搭建Django2.2+Python3+MySQL时新建app时报错:
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

版本信息:

django 2.2.1

mysqlclient 1.3.14

python 3.7

原因:python3.6 myclient的版本过低,与Django不匹配

解决办法:

找到Python安装路径下的…\Lib\site-packages\django\db\backends\mysql\base.py文件

将文件中的如下代码注释:

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

重新在项目manage.py路径下执行命令即可。

  1. AttributeError: ‘str’ object has no attribute ‘decode’
if query is not None:
    query = query.decode(errors='replace')
return query
#改为
if query is not None:
    query = query.encode(errors='replace')
return query
发布了61 篇原创文章 · 获赞 21 · 访问量 9126

猜你喜欢

转载自blog.csdn.net/xbean1028/article/details/102762001