简体   繁体   English

无法在virtualenv中安装mySQL-python

[英]cannot install mySQL-python in virtualenv

When I try to install MySQL-python in a virtualenv ( pip install MySQL-python ), I get the following error (truncated to last few lines) 当我尝试在virtualenv中pip install MySQL-pythonpip install 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

Googling has told me I need to install python-devel , although when I run yum install python-devel I get Googling告诉我我需要安装python-devel ,但是当我运行yum install python-devel时,我会yum install python-devel

Package python-devel-2.6.6-52.el6.x86_64 already installed and latest version
Nothing to do

I am on a CentOS 6.5 box with both python 2.6 and 2.7 installed. 我在同时安装了python 2.6和2.7的CentOS 6.5机器上。 I am using python 2.7 in my virtualenvs. 我在virtualenvs中使用python 2.7。 I have the virtualenv activated when I run pip install mySQL-python . 我在运行pip install mySQL-python时激活了virtualenv。

I have tried running yum install python-devel with both the virtualenv activated and deactivated, it gives the "already installed" message both times. 我尝试在激活和禁用virtualenv的情况下运行yum install python-devel ,它两次都给出“已安装”消息。

Does this mean that the python 27 installation isn't getting the python-devel installation? 这是否意味着python 27安装没有获得python-devel安装?

Another thread suggested to try yum install mysql-devel.x86_64 , although this gives 建议另一个线程尝试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

(using --skip-broken does not work, it just skips it) (使用--skip-broken无效,只会跳过它)

SOLVED: I needed to run sudo yum --enablerepo=remi install mysql-devel 解决:我需要运行sudo yum --enablerepo=remi install mysql-devel

Then, running pip install MySQL-python worked (with my virtualenv activated) 然后,运行pip install MySQL-python起作用(激活了我的virtualenv)

see this answer https://serverfault.com/questions/601162/cant-install-mysql-devel-on-centos-6-5 看到这个答案https://serverfault.com/questions/601162/cant-install-mysql-devel-on-centos-6-5

(I swear I searched for about 1.5 hrs before I posted) (我发誓我在发布之前搜索了约1.5小时)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM