安装MySQL-python报错 error: command 'gcc' failed with exit status 1解决方法

错误如:

_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

要安装的库与系统库冲突了;

解决方法:

1、找出已安装的MySQL:

rpm -qa | grep -i mysql

2、执行如下删除命令:

rpm -ev mysql-5.1.73-3.el6_5.x86_64
rpm -ev mysql-libs-5.1.73-3.el6_5.x86_64
rpm -ev MySQL-python-1.2.3-0.3.c1.1.el6.x86_64

3、重新安装:

yum -y install mysql-devel

4、执行安装命令:

python setup.py build

python setup.py install

5、运行python:

python

搞定!

完美!

你可能感兴趣的:(Linux)