我在CentOS机器上安装了各种版本的python(python2.4和python2.7)。我安装了MySQL-python,但我只能在python2.4上导入MySQLdb模块但不能导入python2.7
root# python2.7
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
root# python
Python 2.4.3 (#1, Mar 5 2011, 21:26:05)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
我已经尝试将python命名为/usr/bin/python2.7,然后删除了MySQL-python&#39;然后做一个安装MySQL-python&#39; yum但没有运气。任何线索/见解?感谢。
答案 0 :(得分:0)
yum会将MySQL-python安装到系统默认的python目录中。
也许你可以尝试virtualenv和pip。