环境

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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Django数据迁移时(或者新建模型时)报错:Did you install mysqlclient,解决后又报错:mysqlclient 1.3.13 or newer is required;you have 0.9.3

    报错信息如下: 解决方法一: 给项目根目录下mysite应用下的__init__.py文件加入如下代码: 运行又报错: 报错信息是:  mysqlclient版本太低 点击上图框中的链接进入到pyth ...

  8. 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,所以不用管它 ...

  9. 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文件中注释以下 ...

随机推荐

  1. CSRF 攻击的应对之道 转载

    CSRF 背景与介绍 CSRF(Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 2007 年曾被列为互联网 20 大安全隐患之一.其他安全隐患,比如 ...

  2. Java连载74-字符串常用方法、正则表达式简介

    一.字符串相关的常用方法简介​ package com.bjpowernode.java_learning; ​ public class D74_1_StringCommonMethod { pub ...

  3. (jsp+servlet+javabean )MVC架构

    MVC是三个单词的缩写,这三个单词分别为:模型.视图和控制. 使用的MVC的目的:在于将M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式.比如Windows系统资源管理器文件夹内容的显示方 ...

  4. 1.(group by)如何让group by分组后,每组中的所有数据都显示出来

    问题描述:表如下,如何让这个表按device_id这个字段分组,且组中的每条数据都查寻出来?(假如说这个表名为:devicedata) 错误答案:select * from devicedata GR ...

  5. [AH2017/HNOI2017] 影魔 - 线段树

    #include<bits/stdc++.h> #define maxn 200010 using namespace std; int a[maxn],st[maxn][2],top,L ...

  6. H5_0012:js事件冒泡和捕获

    捕获(capture)和冒泡(bubble)是事件传播过程中的两个概念, 比如用户单击某个元素, 但由于元素处于父元素内, 该父元素又处于document对象中, document对象又处于windo ...

  7. 实现Windows数据更新

    一.枚举 枚举是一组描述性的名称 定义一组有限的值,不能包含方法 对可能的值进行约束 .定义枚举类 public enum Gender { Male,Female } .使用枚举表示整数值 publ ...

  8. 深入浅出Mybatis系列四-配置详解之typeAliases别名(mybatis源码篇)

    注:本文转载自南轲梦 注:博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 上篇文章<深入浅出Mybatis系列(三)---配置详解之properties ...

  9. 发邮件python

    import smtplib #smtplib是python的一个内置库,所以不需要用pip安装 mailhost='smtp.qq.com' #把qq邮箱的服务器地址赋值到变量mailhost上 q ...

  10. Windows7下Docker的安装

    转自  https://blog.csdn.net/xiangxiezhuren/article/details/79698913 无法打开图3,打开属性.给其添加git路径 无法使用图2下载   h ...