当前位置:网站首页>django. core. exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
django. core. exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
2022-06-28 03:47:00 【wls. wang】
stay ubuntu To establish django Project time , There was a mistake , After consulting relevant materials and documents , Summed up the solution to this error , Whether in the linux in , Still windows or mac In the system , The solution steps are similar , It's just that the location of the file is different
First step :
Download and install PyMySQL, And in the project file with the same name as the project __init__.py Add the following code to . If your image source has not been changed , You can refer to Python Switch pip Mirror source , After change , Download speed will be much faster
# install pymysql
pip install pymysql
# __init__.py
import pymysql
pymysql.install_as_MySQLdb()
The second step :
Method 1 :
Just lower django The version of .# Access terminal , Sometimes according to pip On the version , Need to use pip3 # Input pip uninstall django, Remove django2.2 C:\Users\Administrator>pip uninstall django # Input pip install django==2.1.4, Install version of django C:\Users\Administrator>pip install django==2.1.4If you can't uninstall , Direct installation is also possible
Method 2 :
Continue to use the current version (django=2.2)# find python In the environment django package , And then into db Under the backends Under the mysql Folder cd /home/wls/.local/lib/python3.6/site-packages/django/db/backends/mysqlDon't know django What about the installation directory of ? Continue to read down , Methods are presented immediately
# ubuntu System or windows Under the system # Access terminal , Then enter python, Enter the following command [email protected]:~$ python3 Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> print(django.__path__) ['/home/wls/.local/lib/python3.6/site-packages/django'] # windows Enter the terminal under the system C:\Users\Administrator>pip show django ...... Location: f:\python\lib\site-packagesBoth of the above methods can be found django Installation path for , Is it exciting
The third step :
On the basis of step 2, method 2 , find base.py file , And use vi or vim open base.py file , Comment the relevant code , As shown in the figure below :
# notes base.py The following part of the code in the file
if version < (1, 3, 13):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
It's finally over , Be accomplished , Then there will be errors when running the project , At this time, a cool song should be played , More suitable for the current atmosphere
Error message :
AttributeError: 'str' object has no attribute 'decode'
It is also found in the directory in the previous step operations.py Document and use vi or vim open operations.py file , Comment the relevant code :
# notes operations.py The following part of the code in the file ( This file is a bit long , Take your time ), take decode It is amended as follows encode
# ubuntu in vim Find with shortcut keys : ?decode
if query is not None:
query = query.decode(errors='replace')
return query
# It is amended as follows
if query is not None:
query = query.encode(errors='replace')
return query
And that's it
Articles you may be interested in
边栏推荐
猜你喜欢

Hot! Yolov6's fast and accurate target detection framework is open source (with source code download)

资源管理、高可用与自动化(下)

Idea auto generate code

Dataloader parameter collate_ Use of FN

可扩展存储系统(上)

MySQL configuration of database Series F5 load balancing

Online DDL implementation mechanism in InnoDB of database Series

解析STEAM教育框架下未来教师研究能力

Set drop-down options on Excel files

JVM一:JVM入门以及Class文件认识
随机推荐
Win10 如何删除系统盘大文件hiberfil.sys
力扣每日一题-第29天-219.存在重复元素Ⅱ
组件拆分实战
用于 C# 的 SQL 基本语法总结
多线程与高并发五:等待队列及Executor和线程池详解(重点)
Scalable storage system (I)
第二轮红队免费公开课来袭~明晚八点!
Floating point and complex type of go data type (4)
Database migration
Analysis of slow logs in MySQL and tidb of database Series
基于 LNMP 搭建个人网站的填坑之旅
Change of monitoring documents and folders of "operation and maintenance department"
What is the difference between slice and array in go question bank 12?
Anaconda命令用法
database
事件委托的原理
uni-app 如何根据环境自动切换请求的地址
INFO:&nbsp;HHH000397:&nbsp;Using…
小程序输入框闪动?
电子地图坐标系统研究整理