使用pip2.7安装MySQL-python出现错误

4
我已在CentOS 6.4 64位系统��安装了Python2.7、virtualenv和pip2.7,因为默认版本是Python2.6。但当我尝试使用"pip install mysqlclient"安装mysqldb时:
pip2.7 install MySQL-python

错误发生并且已安装Python-devel软件包。
_mysql.c:2551: error: '_mysql_ConnectionObject' has no member named 'open'

_mysql.c:2558: error: '_mysql_ConnectionObject' has no member named 'converter'

_mysql.c:2565: error: '_mysql_ConnectionObject' has no member named 'connection'

_mysql.c:2572: error: '_mysql_ConnectionObject' has no member named 'connection'

_mysql.c:2579: error: '_mysql_ConnectionObject' has no member named 'connection'

_mysql.c:2642: error: '_mysql_ResultObject' has no member named 'converter'

_mysql.c:2642: error: initializer element is not constant

_mysql.c:2642: error: (near initialization for '_mysql_ResultObject_memberlist[0].offset')

_mysql.c: In function '_mysql_ConnectionObject_getattr':

_mysql.c:2666: error: '_mysql_ConnectionObject' has no member named 'open'

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/MySQL-python/setup.py';exec(compile(getattr(tokenize,

'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-eNCiSQ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/MySQL-python Storing debug log for failure in /root/.pip/pip.log


如果您仍在寻找解决此问题的方法,您可以到另一个StackExchange网站http://superuser.com上寻找更好的机会。 - Cameron
1个回答

3

您好,看起来您没有安装mysql-devel包,这是必须的,以便未编译的源代码和头文件对MySQL-python包可用。

请以root用户运行以下命令:

yum install mysql-devel

请重试!


我也遇到了同样的问题,这正是我所需要的!谢谢!! - Wrenbjor

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接