时间:2021-07-01 10:21:17 帮助过:17人阅读
- <code>python manage.py makemigrations
- or
- python manage.py inspectdb</code>
- <code>django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None</code>
使用注释大法解决:找到自己Python安装路劲下的Python36-32\Lib\site-packages\django\db\backends\mysql\base.py文件 将文件中的如下代码注释(可能需先关闭pycharm IDE)
- <code>if version < (1, 3, 3):
- raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)</code>
py3默认str是unicode编码,通过encode方法编码成bytes类型,后者才有decode解码方法。提示错误来源:Python36\lib\site-packages\django\db\backends\mysql\operations.py", line 149, in last_executed_query
- <code>解决办法:
- 1. 再报错的Python36\lib\site-packages\django\db\backends\mysql\operations.py文件最上面添加
- from django.utils.encoding import force_str
- 2. 将last_executed_query方法中如下代码注释
- query = getattr(cursor, '_executed', None)
- if query is not None:
- query = query.decode(errors='replace')
- return query
- 3. 在注释的代码下添加如下代码:
- return force_str(getattr(cursor, '_executed', None), errors='replace')</code>
- <code>然后再次执行python manage.py makemigrations 成功</code>
参考连接: https://www.zhangshengrong.com/p/281om6qgNw/
django 2.2和mysql使用的常见问题
标签:arm errors operation pychar ISE you 解决 代码注释 支持