Django踩坑之django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you have 0.9.3.

安装Django3后不想折腾mysqlclient那堆库文件,直接装了pymysql替代mysqlclient,报错:django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you have 0.9.3.。实际上pymysql版本号是 0.9.3,却明目张胆篡改version_info欺骗Django??。这样一来就简单了,patch一下这个属性就行了嘛, 修改__init__.py,多插入一行代码:

import pymysql
pymysql.version_info = (1, 3, 13, "final", 0)
pymysql.install_as_MySQLdb()

参考博客:https://yuntianti.com/posts/fix-django3-mysqlclient-import-error/

Django踩坑之django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you have 0.9.3.

上一篇:MySQL的各种日志


下一篇:Oracle学习笔记:dba_tables、all_tables、user_tables区别