How to run pip of different version of python using python command? How to run pip of different version of python using python command? python-3.x python-3.x

How to run pip of different version of python using python command?


Finally I found the solution myself, see the Docs:

https://docs.python.org/3/installing/index.html?highlight=pip#work-with-multiple-versions-of-python-installed-in-parallel

Just call:

pythonXX -m pip install SomePackage

That would work separately for each version of installed python.

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 2py -2.7 -m pip install SomePackage  # specifically Python 2.7py -3   -m pip install SomePackage  # default Python 3py -3.4 -m pip install SomePackage  # specifically Python 3.4


How about using pyenv?

You can switch the version.

$ pyenv install 2.7.X$ pyenv install 3.5.X$ pyenv local 2.7.X$ pyenv global 3.5.X


This solution worked for me:

sudo python2.7 -m pip install [package name]