当前位置:网站首页>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.4
If 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/mysql
Don'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-packages
Both 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
边栏推荐
猜你喜欢
随机推荐
荣耀v8 真机调试时不显示 Logcat 日志的解决办法
可扩展存储系统(上)
数据库乱码问题
Documentation issues
"9 No" principle and "5 measurement dimensions" of extensible system
Is it better for a novice to open a securities account? Is it safe to open a stock trading account
WARN:&nbsp; SQL&nbsp; Error:&nbsp;…
Circular sliding auto adsorption UI tool that monkeys can use
Anaconda command usage
CURDATE()和NOW()区别
多线程与高并发六:线程池源码解析
What is the core problem to be solved in the East and West?
Go 數據類型篇(四)之浮點型與複數類型
uni-app 如何根据环境自动切换请求的地址
一千行 MySQL 学习笔记,值得收藏!
Research and arrangement of electronic map coordinate system
Why is the service implementation class always red
Lamaba表达式学习及常用函数式接口
SSH框架的搭建(下)
vscode中出现无法在只读编辑器中编辑