简体   繁体   中英

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)

_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

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. I am using python 2.7 in my virtualenvs. I have the virtualenv activated when I run pip install mySQL-python .

I have tried running yum install python-devel with both the virtualenv activated and deactivated, it gives the "already installed" message both times.

Does this mean that the python 27 installation isn't getting the python-devel installation?

Another thread suggested to try yum install mysql-devel.x86_64 , although this gives

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)

SOLVED: I needed to run sudo yum --enablerepo=remi install mysql-devel

Then, running pip install MySQL-python worked (with my virtualenv activated)

see this answer 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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