问题描述
我浏览了论坛,但找不到答案,甚至找不到任何相关文档.试图重新创建一个像 www.testandtrack.io 的网站
I've trawled the forums but cannot find an answer or even any documentation on this. Trying to re-create a site like www.testandtrack.io
运行命令:
python manage.py inspectdb
我收到错误:
mysqlclient 1.3.13 or newer is required; you have 0.9.3
我已经尝试了所有建议的修复,包括:- 升级 pip- 使用命令 pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl 安装不同的轮子(32 位而不是 64 位),即 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
如果您使用传统的 env,您的路径将是:
If you use traditional env your path would be:
<env_directory_name>/Lib/site-packages/django/db/base.py
打开文件 base.py 并搜索:
Open file base.py and search for:
version = Database.version_info
在 if 和注释行中放入 pass:
Put a pass inside if and comment line:
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required;你有 %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.
@edit
在得到这个答案之前,我没有找到其他方法来解决它.今天有更好的方法来处理这个问题.这个答案有更好的方法.
Until this answer, I found no other way to solve it. Today there are better ways to deal with this problem. This answer has a better approach.
这篇关于Django - 安装 mysqlclient 错误:需要 mysqlclient 1.3.13 或更新版本;你有 0.9.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)