Installing MySQLdb specifically in python 2.7 on centos

北战南征 提交于 2019-12-24 00:53:31

问题


I'm using CentOS release 6.5 (Final).

I 'm currently using python 2.4, in which I can use MySQL without problems.

root@dedicado [/home/digicelc/public_html/gestion/python/cater]# python
>>> import MySQLdb
>>> 

But, when I try it from python2.7

root@dedicado [/home/digicelc/public_html/gestion/python/cater]# python2.7
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
>>> 

I don't want to change the python version in the server, just want to make the module avaiable for 2.7

Finally this:

# yum install python27-MySQL-python 

Is giving me this:

Error: Package: python27-MySQL-python-1.2.3-9.el6.centos.alt.x86_64 (scl)
           Requires: libmysqlclient_r.so.16()(64bit)
Error: Package: python27-MySQL-python-1.2.3-9.el6.centos.alt.x86_64 (scl)
           Requires: libmysqlclient_r.so.16(libmysqlclient_16)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

回答1:


I had a similar problem. Had to install python2.7 to get a particular library, then couldn't run mysql via python2.7 because it was installed on 2.6.

Try this: pip2.7 install MySQL-python



来源:https://stackoverflow.com/questions/23546452/installing-mysqldb-specifically-in-python-2-7-on-centos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!