RedHat 是我的操作系统。默认情况下它运行 python2.6。但是,我需要安装 python2.7。我按照 this post 安装了它.现在,当我运行时:
$ python -V
Python 2.7.5
不过
$ sudo python -V
Python 2.6.6
所以,我在安装库时遇到了问题。 我尝试通过以下方式安装 mysql-connector:
pip install mysql-connector-python- 在 installation guide for source distribution 之后
- 在 installation guide for binary distribution 之后
但是,mysql-connector 模块没有安装在python 2.7 版本上。如果我运行:
$ python
>>> import mysql.connector
ImportError: No module named mysql.connector
如何在 python 2.7 版上安装 mysql 模块?
编辑
附加信息:
$ which pip
/usr/bin/pip
$ sudo which pip
/usr/bin/pip
$ which easy_install
/opt/rh/python27/root/usr/bin/easy_install
$ sudo which easy_install
/usr/bin/easy_install
/usr/bin/ $ ls -al pip
-rwxr-xr-x. 1 root root 281 Feb 7 11:07 pip
/opt/rh/python27/root/usr/bin $ ls -al easy_install
-rwxr-xr-x. 1 root root 344 Aug 16 11:40 easy_install
请您参考如下方法:
这正是您应该使用 virtualenv 的原因.
