MySQL-python使用pip2.7安装报错

Posted

技术标签:

【中文标题】MySQL-python使用pip2.7安装报错【英文标题】:MySQL-python installation error using pip2.7 【发布时间】:2014-06-11 03:24:56 【问题描述】:

我已经在 centos6.4 64bit 中安装了 Python2.7、virtualenv 和 pip2.7,因为 python2.6 是默认的。

当我尝试使用安装 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'))" 安装 --record /tmp/pip-eNCiSQ-record/install-record.txt --single-version-externally-managed --compile 失败,错误代码 1 在 /tmp/pip_build_root/MySQL-python 在 /root/.pip/pip.log 中存储失败的调试日志

【问题讨论】:

如果您仍在寻找解决此问题的方法,您可能会在另一个 StackExchange 站点上获得更好的运气,superuser.com。 【参考方案1】:

您似乎没有安装 mysql-devel 包,这是必需的,以便未编译的源文件和头文件可用于 MySQL-python 包。

以root身份运行

yum install mysql-devel

再试一次!

【讨论】:

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

以上是关于MySQL-python使用pip2.7安装报错的主要内容,如果未能解决你的问题,请参考以下文章

安装MySQL-python报错

linux安装pip2.7

pip 安装 MySQL-python 报错

Windows下安装MySQLdb(mysql-python)报错解决

解决windows64位系统上安装mysql-python报错

解决python2安装MySQL-python模块报错