网络编程
位置:首页>> 网络编程>> 数据库>> Django启动时找不到mysqlclient问题解决方案

Django启动时找不到mysqlclient问题解决方案

作者:临渊  发布时间:2024-01-17 15:55:29 

标签:Django,启动,mysql,client

在使用Django2.0 并配置了mysql作为数据库时,启动报错:

报错1:找不到mysqlclient

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

Django启动时找不到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

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com