Django-安装mysqlclient错误:需要mysqlclient 1.3.13或更高版本;你有0.9.3 [英] Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3

查看:354
本文介绍了Django-安装mysqlclient错误:需要mysqlclient 1.3.13或更高版本;你有0.9.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经拖曳了论坛,但是找不到答案,甚至找不到任何文档.

I've trawled the forums but cannot find an answer or even any documentation on this.

在运行命令时:

python manage.py inspectdb

我收到错误:

mysqlclient 1.3.13 or newer is required; you have 0.9.3

我尝试了所有建议的修复程序,包括: -升级点 -使用命令pip安装另一个轮子(32位而不是64位),即mysqlclient-1.4.2-cp37-cp37m-win32.whl(安装mysqlclient-1.4.2-cp37-cp37m-win32.whl)(错误,但不能完成所需的工作!)

I have tried all the suggested fixes including: -upgrading pip -installing a different wheel (32 bit instead of 64), namely mysqlclient-1.4.2-cp37-cp37m-win32.whl with the command pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl (this works fine without an error but doesn't do the job required!)

我的目标是简单地将旧版mysql数据库(在XAMPP和myphpadmin中运行)连接到Django.我遵循的文档遗漏了安装mysqlclient的需要,并且此刻被卡住了.

My objective is to simply connect a legacy mysql database (running inside of XAMPP and myphpadmin) to Django. I've followed the documentation which misses out the need to install mysqlclient, and have got stuck at this point.

推荐答案

这是我修复它的方式.

转到django/db/backends/mysql安装目录. 在错误消息中检查您的路径.

Go to your django/db/backends/mysql installation dir. Check your path in the error message.

我正在使用pipenv,因此我的路径是:

I'm using pipenv so my path is:

/home/username/.local/share/virtualenvs/project-env/lib/python3.7/site-packages/django/db/backends/mysql

/home/username/.local/share/virtualenvs/project-env/lib/python3.7/site-packages/django/db/backends/mysql

打开文件base.py并搜索:

Open file base.py and search for:

version = Database.version_info

在if和注释行内放入通过:

Put a pass inside if and comment line:

raise ImproperlyConfigured('mysqlclient 1.3.13或更高版本; 你有%s. %数据库.版本)

raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)

喜欢这个.

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

保存,关闭此文件并打开operations.py.

Save, close this file and open operations.py.

搜索:

query = query.decode(errors='replace')

并更改解码以进行编码

query = query.encode(errors='replace')

现在,尝试运行服务器.

Now, try to run the server.

这篇关于Django-安装mysqlclient错误:需要mysqlclient 1.3.13或更高版本;你有0.9.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆