Bri*_*ach 2 python pip virtualenv mysql-python python-2.7
当我尝试在virtualenv(pip install MySQL-python)中安装MySQL-python时,我收到以下错误(截断到最后几行)
_mysql.c: At top level:
_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
Run Code Online (Sandbox Code Playgroud)
谷歌搜索告诉我,我需要安装python-devel,但是当我跑步时,yum install python-devel我得到了
Package python-devel-2.6.6-52.el6.x86_64 already installed and latest version
Nothing to do
Run Code Online (Sandbox Code Playgroud)
我在安装了python 2.6和2.7的CentOS 6.5机箱上.我在virtualenvs中使用python 2.7.我跑的时候激活了virtualenv pip install mySQL-python.
我试过运行yum install python-develvirtualenv激活和停用,它两次都给出"已安装"消息.
这是否意味着python 27安装没有得到python-devel安装?
另一个线程建议尝试yum install mysql-devel.x86_64,虽然这给了
Resolving Dependencies
--> Running transaction check
---> Package mysql-devel.x86_64 0:5.1.73-3.el6_5 will be installed
--> Processing Dependency: mysql = 5.1.73-3.el6_5 for package: mysql-devel-5.1.73-3.el6_5.x86_64
--> Finished Dependency Resolution
Error: Package: mysql-devel-5.1.73-3.el6_5.x86_64 (base)
Requires: mysql = 5.1.73-3.el6_5
Installed: mysql-5.5.40-1.el6.remi.x86_64 (@remi)
mysql = 5.5.40-1.el6.remi
Available: mysql-5.1.73-3.el6_5.x86_64 (base)
mysql = 5.1.73-3.el6_5
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
Run Code Online (Sandbox Code Playgroud)
(使用--skip-broken不起作用,它只是跳过它)
解决:我需要跑 sudo yum --enablerepo=remi install mysql-devel
然后,运行pip install MySQL-python工作(我的virtualenv激活)
看到这个答案https://serverfault.com/questions/601162/cant-install-mysql-devel-on-centos-6-5
(我发誓我在发布之前搜索了大约1.5小时)