Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3
环境
Deepin Linux 15.11
Django 2.2
pymysql0.9.3
原因
因为用pymysql替换了默认的mysqlclient,Django官方推荐的数据库API driver是mysqlclient。
https://docs.djangoproject.com/en/2.2/ref/databases/#mysql-db-api-drivers
解决方法1 使用mysqlclient,去除pymysql
不要用pymysql。用mysqlclient。
安装方法:https://github.com/PyMySQL/mysqlclient-python#install
解决方法2 仍然使用pymysql
2.1 配置文件的目录中_init_.py中有如下代码
import pymysql
pymysql.install_as_MySQLdb() # 这是一个hack,为了在Djano中替代默认的mysqlclient。mysqlclient官方描述:This is a fork of MySQLdb1
2.2 点进去install_as_MySQLdb
找到version_info变量,改成
version_info = (1, 3, 13, "final", 0)
2.3 改变django.db.backends.mysql.operations.py的一行代码
query = query.decode(errors='replace') -> query = query.encode(errors='replace')
原因:mysqlclient returns bytes object, PyMySQL returns str object
参考:https://github.com/PyMySQL/PyMySQL/issues/790#issuecomment-484201388
解决方法3 仍然使用pymysql,和解决方法2类似
https://stackoverflow.com/a/55954355/5955399
解决方法4 init.py里面
import pymysql
pymysql.version_info = (1, 4, 6, 'final', 0) # change mysqlclient version
pymysql.install_as_MySQLdb()
Django - installing mysqlclient error: mysqlclient 1.3.13 or newer is required; you have 0.9.3的更多相关文章
- Django2.2报错 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
准备将 Django 连接到 MySQL,在命令行输入命令 python manage.py makemigrations 后报错: django.core.exceptions.Improperly ...
- django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2的最佳处理方法,亲测可用
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.2 ...
- Django项目配置数据库时,已安装mysqlclient,却提示 Did you install mysqlclient错误,后右报错ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
错误信息如下: 解决方案是: 找到自己的项目文件夹下的__init__.py 添加如下代码 解决这个问题后,右报错django2.2/mysql ImproperlyConfigured: mysq ...
- django2.2/mysql ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
报错环境 python=3.6.5,django=2.2,PyMySQL=0.9.3 …… django.core.exceptions.ImproperlyConfigured: mysqlcl ...
- exceptions: django2.2/ mysql ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
在centos部署python应用后访问页面,显示如下异常信息 报错环境 python=3.6,django=2.2……django.core.exceptions.ImproperlyConfigu ...
- django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.解决办法
"E:\API_Manager_PlatForm\venv\lib\site-packages\django\db\backends\mysql\base.py"在这个路径里件把b ...
- Django数据迁移时(或者新建模型时)报错:Did you install mysqlclient,解决后又报错:mysqlclient 1.3.13 or newer is required;you have 0.9.3
报错信息如下: 解决方法一: 给项目根目录下mysite应用下的__init__.py文件加入如下代码: 运行又报错: 报错信息是: mysqlclient版本太低 点击上图框中的链接进入到pyth ...
- django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
异常汇总:https://www.cnblogs.com/dotnetcrazy/p/9192089.html 这个是Django对MySQLdb版本的限制,我们使用的是PyMySQL,所以不用管它 ...
- Django生成脚本迁移文件时,报错django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
一.本人环境:django:3.0.2, python:3.8.1, pymysql:0.9.3 二.解决步骤: 1.django目录下找到 base.py文件: 2.在base.py文件中注释以下 ...
随机推荐
- Elasticsearch集成IKAnalyzer分析器
1. 查看标准分析器的分词结果 http://127.0.0.1:9200/_analyze?analyzer=standard&text=标准分析器 都分成了单个汉字, ...
- Linux系统的启动原理
Linux系统的启动原理 RHEL的启动原理BIOS自检-MBR-启动GRUB-加载内核-systemd的init进程 systemd的初始化进程加载需要的服务,挂载文件系统/etc/fstabsys ...
- HTTP协议、时间戳、防盗链的一些概念
HTTP协议 什么是HTTP协议 (HyperText Transfer Protocol,超文本传输协议)是因特网上应用最为广泛的一种网络传输协议,所有的WWW文件都必须遵守这个标准. HTTP是一 ...
- [转]Maven的pom.xml文件详解
Maven的pom.xml文件详解------Build Settings 2013年10月30日 13:04:01 阅读数:44678 根据POM 4.0.0 XSD,build元素概念性的划分为两 ...
- Redis的主从复制与Redis Sentinel哨兵机制
1 Redis的主从复制 1.1 什么是主从复制 持久化保证了即使redis服务重启也不会丢失数据,因为redis服务重启后会将硬盘上持久化的数据恢复到内存中,但是当redis服务器的硬盘损 ...
- P6070 [RC-02] GCD [杜教筛,莫比乌斯反演]
没啥好说的,杜教筛板子题. \[\sum_{i=1}^{N} \sum_{j=1}^{N}\sum_{p=1}^{\lfloor \frac{N}{j} \rfloor}\sum_{q=1}^{\lf ...
- Windows新建域时 administrator账户密码不符合要求解决办法~!
解决方法 在cmd 命令行中 输入 net user administrator /passwordreq:yes
- 使用VSCode创建简单的Razor Webapp--1.入门
1.下载vscode,安装dotnet core sdk 在cmd中使用命令dotnet --version可以查看当前安装的版本 2.打开vscode,设置语言和扩展 在最左边的工具栏,点击最下面的 ...
- Keep、小红书、美图…独角兽App能拿到新一轮救命钱吗?
大多数人热爱手机,不是因为时尚的外观或者结实的零部件,而是因琳琅满目的App赋予其太多的功能.智能手机最先是清理掉人类的零碎时间,现如今又开始肢解我们大块的时间,或者说,智能手机本身就是生活.在如此背 ...
- 4817 [Sdoi2017]树点涂色
题目描述 Bob 有一棵 n 个点的有根树,其中 1 号点是根节点.Bob 在每个点上涂了颜色,并且每个点上的颜色不同. 定义一条路径的权值是:这条路径上的点(包括起点和终点)共有多少种不同的颜色. ...