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

出现错误:django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?

在这里插入图片描述
1、检查mysqlclient是否安装
Django使用MySQL数据库需要加载 MySQLdb模块,

pip install mysqlclient

pip show mysqlclient

2、已安装情况下仍然报错
项目(settings.py同级)目录中__init__.py中添加

import pymysql
pymysql.install_as_MySQLdb()

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_22938603/article/details/124456172