Django2.2连接mysql数据库出现django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None问题

在使用Django2.2开发的时候,想要使用mysql数据库,在settings.py文件中更改命令:

DATABASES = {
‘default‘: {
‘ENGINE‘: ‘django.db.backends.mysql‘,
‘NAME‘: ‘python‘,
‘USER‘: "root",
‘PASSWORD‘: "yhr2323214310",
‘HOST‘: ‘‘,
‘PORT‘: ‘‘

}
}

再安装好pymysql,然后在__init__.py文件中添加:

import pymysql

pymysql.install_as_MySQLdb()

然后在models中创建好表类后,进行数据迁移时出现问题:

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None

上网查一下解决方法,费了好大劲

解决方法:

1.找到base.py文件,我的是在~/PycharmProject/myBlog/venv/lib/python3.6/site-packages/django/db/backends/mysql/base.py

就是在你项目文件夹下的/venv/lib/python3.6/site-packages/django/db/backends/mysql/中

进去进行修改:

找到这段代码:version = Database.version_info

修改下面的if语句:添加pass,再注释掉,就像这个样子:

if version < (1, 3, 13):
pass
‘‘‘
raise ImproperlyConfigured(‘mysqlclient 1.3.13 or newer is required; you have %s.‘ % Database.__version__)
‘‘‘

保存后,在进入同路径下的operations.py文件

将query = query.decode(errors=‘replace‘)中的decode改为encode

保存

再次进行数据迁移,成功!可以成功连接到mysql。

原文地址:https://www.cnblogs.com/Horace-blogs/p/11357232.html

时间: 2024-10-11 00:02:08

Django2.2连接mysql数据库出现django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None问题的相关文章

关于报错:django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None

线上项目转到测试,setting连接本地数据库报错. 1 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None Python安装路劲下的Python36-32\Lib\site-packages\django\db\backends\mysql\base.py文件下. 注释下面语句 1 if version < (1, 3, 3): 2 r

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.9.3.None

报错环境: python=3.7,django=2.2,PyMySQL=0.9.3 抛出异常: django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 报错场景: 1.启动django项目 2.更新表:python manage.py makemigrations 报错原因:安装Django后不想折腾mysqlclient那堆库文件,直接装了pymy

Django3 中遇到django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you have 0.9.3.异常的解决方案

转自:https://yuntianti.com/posts/fix-django3-mysqlclient-import-error/ Django 近期发布了3.0版本,其中首度支持了asyncio让人兴奋, 为此引入了新的网关接口协议ASGI.按异步IO的实现原理,即使使用ASGI替代WSGI部署Web应用,如果使用了一些同步库,肯定还是会阻塞IOLoop的,使应用失去异步特性.但是Django的应用场景很多是有状态的,不得不使用一些带状态的库和函数.比如在MySQL中执行事务,或一些前后

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. | Django报错

Django报错 | "django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.问题解决方案 1 问题分析 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 解读:django.core.except

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,所以不用管它 原文地址:https://www.cnblogs.com/dotnetcrazy/p/10779304.html

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: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 解决方法: Django连接MySQL时默认使用MySQLdb驱动,但MySQLdb不支持Python3,因此这里将MySQL驱动设置为pymysql,使用 pip install pymysql 进行安

Django启动时找不到mysqlclient处理 django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

在使用Django2.0 并配置了mysql作为数据库时,启动报错: 报错1:找不到mysqlclient django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? 解决方法 项目(settings.py同级)目录中__init__.py中添加 import pymysql pymysql.install_as_MySQLdb() 报错2:版本检查

后台创建管理员 createsuperuser 时 报django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

结果版本0.9.3 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3. 需要pip指定版本号安装 结果清华源没有这个版本,换阿里云 pip install -i https://mirrors.aliyun.com/pypi/simple/ pymysql==1.3.13 阿里也没有,只能国外了 pip install jupyter -i ht

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

1.使用Python3.7 + Django2.2 + MySQL 5.5 在执行(python manage.py migrate)命令时出现错误django.db.migrations.exceptions.MigrationSchemaMissing 原因是 所以,需要重新安装高版本的sql,安装好之后,问题就解决了 2.Django数据同步过程中遇到的问题: 1)raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is requ