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

2024-06-10 06:35:48 发布

您现在位置:Python中文网/ 问答频道 /正文

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

[ethan@demo ~]$ python2.6 --version
Python 2.6.6
[ehtan@demo ~]$ python --version
Python 2.7.3

一些基本的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()

编辑

我找到了这个答案,但对我不起作用


Tags: pipindemoonversionhattypered