处理多个Python版本和PIP? [英] Dealing with multiple Python versions and PIP?

查看:146
本文介绍了处理多个Python版本和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}.

是的,我了解virtualenv,不,这不是解决此特定问题的方法.

And, yes — I know about virtualenv, and no — it's not a solution to this particular problem.

推荐答案

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


编辑:在1.5版中,pip更改了其架构以使用pipVERSION代替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 了解更多详情

参考文献:

  • https://github.com/pypa/pip/issues/200
  • http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4

这篇关于处理多个Python版本和PIP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆