Error loading MySQLdb module. Did you install mysqlclient ?

作者:admin 发布:2019-03-25 浏览:1240次

操作系统:centos 7.6

Python:3.6.6

Django:2.1.5


运行程序报错:

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


如果执行

pip install mysqlclient


报错:


 OSError: mysql_config not found

    

    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-07k4ml5p/mysqlclient/


解决:

pip install PyMySQL


__init__.py 中加入

import pymysql
pymysql.install_as_MySQLdb()


Comments (0)