Django启动时找不到mysqlclient问题解决方案
作者:临渊 时间:2024-01-17 15:55:29
在使用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:版本检查出错
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
解决方法:
找到Python安装路劲下的/Users/MAC/env/MxShop/lib/python3.6/site-packages/django/db/backends/mysql/base.py文件
将文件中的如下代码注释
#if version < (1, 3, 3):
# raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
重新在项目manage.py路劲下执行如下命令即可
来源:https://www.cnblogs.com/superhin/p/12341697.html
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
从浏览器想开去
python3实现从kafka获取数据,并解析为json格式,写入到mysql中
python计算圆周长、面积、球体体积并画出圆
![](https://img.aspxhome.com/file/2023/6/135126_0s.jpg)
golang goquery selector选择器使用示例大全
pytorch载入预训练模型后,实现训练指定层
Pycharm使用时会出现的问题之cv2无法安装解决
![](https://img.aspxhome.com/file/2023/0/118370_0s.jpg)
ASP 循环导入导出数据处理 不使用缓存
用js更好地截取定长字符串
MySQL派生表联表查询实战过程
![](https://img.aspxhome.com/file/2023/4/95624_0s.png)
Golang通过包长协议处理TCP粘包的问题解决
![](https://img.aspxhome.com/file/2023/2/130742_0s.png)
Python ORM框架SQLAlchemy学习笔记之安装和简单查询实例
详解用python实现简单的遗传算法
![](https://img.aspxhome.com/file/2023/8/123698_0s.png)
详解python做UI界面的方法
![](https://img.aspxhome.com/file/2023/0/105590_0s.png)
Asp.net清空控件值的方法(可自定义控件类型)
利用PyCharm操作Github(仓库新建、更新,代码回滚)
![](https://img.aspxhome.com/file/2023/3/83653_0s.png)
python实现桌面气泡提示功能
![](https://img.aspxhome.com/file/2023/0/94070_0s.jpg)
js对象内部访问this修饰的成员函数示例
python 视频逐帧保存为图片的完整实例
Python字符串的创建和驻留机制详解
![](https://img.aspxhome.com/file/2023/3/99193_0s.png)
Python脚本开发漏洞的批量搜索与利用(GlassFish 任意文件读取)
![](https://img.aspxhome.com/file/2023/1/93611_0s.png)