环境

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. Interger对象不要用==进行比较

    为了更好的空间和时间性能,Integer会缓存频繁使用的数值,数值范围为-128到127,在此范围内直接返回缓存值. IntegerCache.low 是-128,IntegerCache.high是

  2. C#简单的LogHelper

    适用于不想使用log4net等第三方的Log工具的LogHelper.正规的还是要使用<C# 工具类LogHelper>的这种做法. using System; using System. ...

  3. Api跨域设置

    跨域设置:(服务端) webconfig文件中,system.webServer节点下添加 <!--跨域请求:三个配置信息--> <httpProtocol> <cust ...

  4. .net core3.0 webapi搭建(一)

    一.创建WebApi项目: 生成项目之后,控制器默认生成了一个WeatherForecastController 我们可以直接启动项目,F5调试,默认进入WeatherForecastControll ...

  5. jquery的封装与对象学习

    1.封装学习 /// <reference path="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" /> ...

  6. pygame 运行心理学问卷

    import pygame import sys from pygame.locals import * # wait for keys to putdown def waitForKeys(keys ...

  7. vue.js中用npm安装vue-router时报错处理办法

    当在使用npm安装东西的时候,最怕遇到的就是,电脑并不想和你说话,只向你抛出一大堆错误...比如在vue.js中用npm安装vue-router的时候,我就遇到 一脸蒙逼的我默默的念了一句:卧..槽. ...

  8. unity中ContentSizeFitter刷新不及时的问题

    ContentSizeFitter,自适应宽高脚本要在下一帧的时候才会适应宽高.如果想立即生效,可以调用 LayoutRebuilder.ForceRebuildLayoutImmediate(rec ...

  9. SpringBoot之Configuration

      在SpringBoot中可以通过@Configuration对某个类注解将该类申明为配置类,以此在代替先前spring版本中配置xml中的功能,并且增加了可读性与维护性.并且在注解类中的类方法中可 ...

  10. JAVA StringUtils工具类

    org.apache.commons.lang Class StringUtils java.lang.Object org.apache.commons.lang.StringUtils publi ...