django使用mysql报错 Error loading MySQLdb module: No module named 'MySQLdb'处理

错误原因:

python3中已经取消了MySQLdb包

处理办法

安装pymysql包
pip install PyMySQL 

以以下目录结构为例,在test5/test5/init.py中添加如下代码:

import pymysql
pymysql.install_as_MySQLdb()

├── booktest
│ ├── admin.py
│ ├── apps.py
│ ├── init.py
│ ├── migrations
│ │ ├── init.py
│ │ └── pycache
│ ├── models.py
│ ├── pycache
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── manage.py
├── static
│ └── booktest
│ └── a1.jpg -> /usr/share/wallpapers/deepin/Flying_Whale_by_Shu_Le.jpg
├── templates
│ └── index.html
└── test5
├── init.py
├── pycache
├── settings.py
├── urls.py
└── wsgi.py
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lb0737/article/details/88987546