[英]How to get pip to point to newer version of Python
I have two versions of Python
installed on my centOS
server. 我的
centOS
服务器上安装了两个版本的Python
。
[ethan@demo ~]$ python2.6 --version
Python 2.6.6
[ehtan@demo ~]$ python --version
Python 2.7.3
The older version (2.6) is required by some essential centOS
packages so I can't remove it. 一些基本的
centOS
软件包需要旧版本(2.6),所以我无法将其删除。
When I install packages using pip
, they are being installed in Python 2.6
. 当我使用
pip
安装软件包时,它们将安装在Python 2.6
。 But instead I want them to be installed to Python 2.7
. 但相反,我希望它们安装到
Python 2.7
。
How can I change this behaviour? 我该如何改变这种行为?
For example, here is what happened when I tried installing Wand
例如,这是我尝试安装
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()
Edit 编辑
I found this answer but it didn't work for me https://stackoverflow.com/a/4910393/3384340 我找到了这个答案,但它对我不起作用https://stackoverflow.com/a/4910393/3384340
You need to install pip for each python version separately. 你需要分别为每个python版本安装pip。
In order to install pip for Python2.7, run 为了安装Python2.7的pip,请运行
sudo easy_install-2.7 pip
Use pip-2.7 to install Wand
使用pip-2.7安装
Wand
sudo pip-2.7 install Wand
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.