I created the following alias to run pip3.7 everytime I use pip command:
pip='pip3.7'Now, bash says:
pip -V pip 18.1 from /home/uname/.local/lib/python3.7/site-packages/pip (python 3.7)but, the command which pip says:
which pip /home/uname/.local/bin/pipwhile the executables for pip3.7 seem to be located at different folders:
whereis pip3.7: /usr/local/bin/pip3.7 /home/uname/.local/bin/pip3.7 /home/uname/.local/bin/pip3I think maybe that in which pip, the world pip is not seen as the command actually triggered by the alias, thus it returns the pip path like if alias would not exist. This confuses me on which version actually runs with pip command.
2 Answers
which can only find executables in the PATH.
type is a Bash builtin, and will show aliases, plus other Bash-internal commands like functions, keywords, and builtins, plus executables and hashed executables.
Example shell session:
$ pip -V
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)
$ alias pip=pip3
$ type pip
pip is aliased to `pip3'
$ type pip3
pip3 is /usr/local/bin/pip3
$ which pip
/usr/local/bin/pip
$ pip -V
pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
$ type pip3
pip3 is hashed (/usr/local/bin/pip3) 1 It depends what python interpreter you want to use. You can install same python and pip several times on one machine.
If you want to use standard python like
apt install python3
apt install python3-pipthen you can set alias as
alias pip='/usr/bin/pip3'If you want to use a different installation of python I recommend using python virtual environment. You can install it with
apt-get install python3-venvYou can also find several tutorials in internet on how to use python virtual environment.