如何使用python命令运行不同版本的python的pip? [英] How to run pip of different version of python using python command?
问题描述
我现在在ubuntu 15.10上使用Python
I'm now currently using Python on ubuntu 15.10
但是在我的操作系统中,我安装了许多不同的python版本:
But in my OS, I have many different python version installed:
- Python(2.7.9)
- Python3(3.4.3)
- Python3.5
- PyPy
因此,例如,如果我运行它们,我会迷惑他们的软件包环境的版本:
So, I got mess about the version of their package environment, for example, if I run:
pip3 install django
实际上我无法在python3.5
内导入django.
In fact I cannot import django inside python3.5
.
有没有有效的方法来调用pip
的相关版本?
Is there any efficiently way to call the relating version of pip
?
PS:不要建议我使用virtualenv,我知道这一点,正在寻求其他解决方案.
推荐答案
最后我自己找到了解决方案,请参阅文档:
Finally I found the solution myself, see the Docs:
只需拨打电话
pythonXX -m pip install SomePackage
这对于已安装的python的每个版本都是单独工作的.
That would work separately for each version of installed python.
另外,根据文档,如果我们想在Windows中执行相同的操作,则命令有些不同:
Also, according to the docs, if we want to do the same thing in windows, the command is a bit different:
py -2 -m pip install SomePackage # default Python 2
py -2.7 -m pip install SomePackage # specifically Python 2.7
py -3 -m pip install SomePackage # default Python 3
py -3.4 -m pip install SomePackage # specifically Python 3.4
这篇关于如何使用python命令运行不同版本的python的pip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!