处理多个 Python 版本和 PIP? [英] Dealing with multiple Python versions and PIP?
问题描述
有什么方法可以让 pip
与多个版本的 Python 兼容?例如,我想使用 pip
将内容显式安装到我的站点 2.5 安装或站点 2.6 安装.
Is there any way to make pip
play well with multiple versions of Python? For example, I want to use pip
to explicitly install things to either my site 2.5 installation or my site 2.6 installation.
例如,对于 easy_install
,我使用 easy_install-2.{5,6}
.
For example, with easy_install
, I use easy_install-2.{5,6}
.
而且,是的——我知道 virtualenv,但不——它不是这个特定问题的解决方案.
And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.
推荐答案
当前建议 是使用 python -m pip
,其中 python
是您要使用的 Python 版本.这是推荐的,因为它适用于所有版本的 Python,以及所有形式的 virtualenv.例如:
The current recommendation is to use python -m pip
, where python
is the version of Python you would like to use. This is the recommendation because it works across all versions of Python, and in all forms of virtualenv. For example:
# The system default python:
$ python -m pip install fish
# A virtualenv's python:
$ .env/bin/python -m pip install fish
# A specific version of python:
$ python-3.6 -m pip install fish
以前的答案,留给后人:
Previous answer, left for posterity:
从 0.8 版本开始,Pip 支持 pip-{version}
.您可以像 easy_install-{version}
一样使用它:
Since version 0.8, Pip supports pip-{version}
. You can use it the same as easy_install-{version}
:
$ pip-2.5 install myfoopackage
$ pip-2.6 install otherpackage
$ pip-2.7 install mybarpackage
<小时>
EDIT:pip 将其架构更改为使用 pipVERSION
而不是 1.5 版中的 pip-VERSION
.如果您有 pip >= 1.5
,则应使用以下内容:
EDIT: pip changed its schema to use pipVERSION
instead of pip-VERSION
in version 1.5. You should use the following if you have pip >= 1.5
:
$ pip2.6 install otherpackage
$ pip2.7 install mybarpackage
检查 https://github.com/pypa/pip/pull/1053更多详情
参考文献:
这篇关于处理多个 Python 版本和 PIP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!