如何让pip指向更新版本的Python
我在我的 centOS
服务器上安装了两个版本的 Python
。
[ethan@demo ~]$ python2.6 --version
Python 2.6.6
[ehtan@demo ~]$ python --version
Python 2.7.3
旧版本(2.6)是一些重要的 centOS
软件包所必需的,所以我不能把它删掉。
当我使用 pip
安装软件包时,它们会被安装到 Python 2.6
上。但我其实想把它们安装到 Python 2.7
上。
我该怎么改变这种情况呢?
比如,我尝试安装 Wand
时发生了这样的事情:
[ethan@demo ~]$ pip install Wand
Requirement already satisfied (use --upgrade to upgrade): Wand in /usr/lib/python2.6/site-packages
Cleaning up...
[ethan@demo ~]$ python2.6
Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wand
>>> exit()
[ethan@demo ~]$ python
Python 2.7.3 (default, Oct 11 2013, 15:59:28)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wand
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named wand
>>> exit()
编辑
我找到过一个答案,但对我没用 https://stackoverflow.com/a/4910393/3384340
1 个回答
5
你需要为每个版本的Python单独安装pip。
如果你想为Python2.7安装pip,可以运行以下命令:
sudo easy_install-2.7 pip
接着,使用pip-2.7来安装 Wand
这个库。
sudo pip-2.7 install Wand