报错环境 python=3.6.5,django=2.2,PyMySQL=0.9.3
……
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

解决方法:
Django连接MySQL时默认使用MySQLdb驱动,但MySQLdb不支持Python3,因此这里将MySQL驱动设置为pymysql,使用 pip install pymysql 进行安装,然后在工程文件__init__.py添加以下代码即可。

#安装pymysql
pip install pymysql
#__init__.py
import pymysql
pymysql.install_as_MySQLdb()

第一种:
django降到2.1.4版本就OK了

第二种(仍使用django 2.2版本):

#找到Python环境下 django包,并进入到backends下的mysql文件夹
cd /opt/anaconda3/envs/envAGC_Mini/lib/python3.6/site-packages/django/db/backends/mysql
#文件列表如下

# 找到base.py文件,注释掉 base.py 中如下部分(35/36行)
if version < (1, 3, 3):
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)

此时仍会会报错,报错信息如下:

AttributeError: ‘str’ object has no attribute ‘decode’

#找到operations.py文件(146行),将decode改为encode
#linux vim 查找快捷键:?decode
if query is not None:
query = query.decode(errors='replace')
return query
#改为
if query is not None:
query = query.encode(errors='replace')
return query

OK~ 不再报错

原文链接在这里

django2.2/mysql ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3的更多相关文章

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

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

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

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

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

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

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

  8. django.db.migrations.exceptions.MigrationSchemaMissing和raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

    1.使用Python3.7 + Django2.2 + MySQL 5.5 在执行(python manage.py migrate)命令时出现错误django.db.migrations.excep ...

  9. 报错: raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

    Django2.0同步Mysql数据库时出现的问题 执行 python manage.py makemigrations 报错 # 报错位置 File "G:\python\lib\site ...

随机推荐

  1. HTML5:离线存储

    最近由于找工作一直没时间也没有精力更新博客,找工作真是一件苦逼的事情啊...不抱怨了,我们来看看HTML5的新特性---离线存储吧. 随着Web App的发展,越来越多的移动端App使用HTML5的方 ...

  2. 2、vuex页面刷新数据不保留,解决方法(转)

    今天这个问题又跟页面的刷新有一定的关系,虽然说跟页面刷新的关系不大,但确实页面刷新引起的这一个问题. 场景: VueX里存储了 this.$store.state.PV这样一个变量,这个变量是在app ...

  3. NTFS文件系统详细分析

    NTFS文件系统详细分析 第一部分 什么是NTFS文件系统 想要了解NTFS,我们首先应该认识一下FAT.FAT(File   Allocation   Table)是“文件分配表”的意思.对我们来说 ...

  4. 干货|爱奇艺CDN巡检系统技术解析

    小结: 1. 中心处理系统 /1/将定制后的巡检任务拆分,通过配置与任务分发系统.CMDB*( configuration management database)将派发到边缘拨测系统/2/处理边缘拨 ...

  5. SIM7600C读写本机号码

    1 先发送AT+CPBS = "ON",表示要操作的是本机号码区域,而不是SIM的电话本 2 写入命令AT+CPBW=1,"1234567" 3 读取命令AT+ ...

  6. 新手上路、安装JDK教程

    按照以下的图片步骤,登录http://www.oracle.com 下载 JDK (J2SE)  JDK 1.0, 1.1, 1.2, 1.3, 1.4    1.5.(JDK5.0) → 支持注解. ...

  7. MFC 修改标题

    1. Overwrite CMainFrame::PreCreateWindow. Clear the style FWS_ADDTOTITLE cs.style &= ~(LONG)FWS_ ...

  8. IP的面向无连接状态

    ip是面向于无连接的状态,在发包前,不需要建立与对端目标地址之间的连接. ip采用面向无连接的原因? 面向连接比无连接复杂,此外每次通信前都要事先建立连接,会降低处理速度.需要有连接时可以委托上一层提 ...

  9. sizeof操作符的一些例子

    例一: #include <iostream> using namespace std; class A { public: char c; }; class B { public: in ...

  10. [译]《Sphinx权威指南》 - Sphinx入门

    本章中,我们会讨论到Sphinx基础的安装.配置和维护.不要被“基础”这形容词糊弄而跳过这个章节.对于“基础”,我不是指简单到显而易见的东西,而是指所有人都会用到的功能. 一般来说,Sphinx会使用 ...