如何让pip指向更新版本的Python

Eth*_*han 6 python pip python-2.6 python-2.7

Python我的centOS服务器上安装了两个版本.

[ethan@demo ~]$ python2.6 --version
Python 2.6.6
[ehtan@demo ~]$ python --version
Python 2.7.3
Run Code Online (Sandbox Code Playgroud)

某些基本centOS软件包需要旧版本(2.6),因此我无法将其删除.

当我使用安装软件包时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()
Run Code Online (Sandbox Code Playgroud)

编辑

我找到了这个答案,但它对我不起作用/sf/answers/343727541/

For*_*rge 5

你需要分别为每个python版本安装pip.

为了安装Python2.7的pip,请运行

sudo easy_install-2.7 pip

使用pip-2.7进行安装 Wand

sudo pip-2.7 install Wand