如何使用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屋!