TL;DR
Each installed version of python have its own version of pip executable (at least for ubuntu), e.g. python2
have related pip2
, python3
- pip3
.
python
and pip
is just defaults which is simplinks to python2
or python3
binary.
So you can use
pip3 install <package>
in most cases when you need to install package for python 3.
Lets find out how it works
pip
is not binary!
Look at command for running pip python package, by executing following command:
$ less $(which pip)
Output will be something like this:
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.5.4','console_scripts','pip'
__requires__ = 'pip==1.5.4'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
)
Actually, most of commands in linux aren't binaries. A lot of them just helpful bindings, just like in case with pip.
$ ls -lah $(which pip)
-rwxr-xr-x 1 root root 281 ัะตั 17 00:52 /usr/bin/pip
You can find simple description of how executable scripts works on linux. It is written for bash scripts but applied for any interpreted language: python, javascript, ruby, etc.
So, if pip is not binary, then what does this script?
RTFM about pip, in few words, pip is just a python module and can be executed as any other python module, look at PEP 0338, e.g.
$ python -m pip install <package>
have same same effect as for command
$ pip install <package>
Summary
pip
is python script that runs pip package with passed parameters. Package relative for python version in $ which pip
file. If you will open your pip script, you will find for which python version it is related for.
In my case it is:
$ head -1 $(which pip)
#!/usr/bin/python
$ /usr/bin/python -V
Python 2.7.6
or oneliner
$ $(expr substr `head -1 $(which pip)` 3 100) -V
Python 2.7.6