Error loading MySQLdb module: No module named MySQLdb 错误的解决方法

分类:数据库    发布时间:2017-11-16 11:42:16
具体报错如下:
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的模块安装成功


标签: mysql python

阅读(50)┆ 评论(0) ┆ (0) ┆ 返回博客首页


发表我的评论

欢迎您: | 退出登录


文章评论