具体报错如下:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
解法办法:
需要安装python连接mysql的模块
注意:本人使用yum install MySQL-pyton安装后依然报上错误,经测试必须要pip方式安装
pip install mysql-python
如果安装报以下错误:
pip install pandas` gives UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xe2 in position 41: ordinal not in range(128)
则需要升级pip版本:
pip install --upgrade pip
升级完成后重装安装mysql-python
pip install mysql-python
如果安装报以下错误:
_mysql.c:2091: error: ‘r’ undeclared (first use in this function)
_mysql.c:2091: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:2092: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c: In function ‘_mysql_ResultObject_dealloc’:
_mysql.c:2100: warning: implicit declaration of function ‘mysql_free_result’
_mysql.c:2100: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c: At top level:
_mysql.c:2331: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
_mysql.c:2338: error: ‘_mysql_ConnectionObject’ has no member named ‘converter’
_mysql.c:2345: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:2352: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:2359: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:2422: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:2422: error: initializer element is not constant
_mysql.c:2422: error: (near initialization for ‘_mysql_ResultObject_memberlist[0].offset’)
_mysql.c: In function ‘_mysql_ConnectionObject_getattr’:
_mysql.c:2444: error: ‘_mysql_ConnectionObject’ has no member named ‘open’
error: command ‘gcc‘ failed with exit status 1
解决方法:yum -y install mysql-devel libxml2 libxml2-dev libxslt* zlib gcc openssl
安装完成后再次尝试安装mysql-python
pip install mysql-python
[xxxx@test1 Craxsxx]# pip install mysql-python
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Installing collected packages: mysql-python
Running setup.py install for mysql-python
Successfully installed mysql-python-1.2.5
mysql-python的模块安装成功
本文出自 “小五台车神” 博客,请务必保留此出处http://linuxtech.blog.51cto.com/3670088/1732301
Error loading MySQLdb module: No module named MySQLdb 错误的解决方法
原文地址:http://linuxtech.blog.51cto.com/3670088/1732301