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

2024-01-04

我有两个版本Python安装在我的centOS服务器。

[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()

Edit

我找到了这个答案,但它对我不起作用https://stackoverflow.com/a/4910393/3384340 https://stackoverflow.com/a/4910393/3384340


您需要为每个 python 版本单独安装 pip。

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

sudo easy_install-2.7 pip

使用pip-2.7安装Wand

sudo pip-2.7 install Wand

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何让 pip 指向较新版本的 Python 的相关文章

随机推荐