I created the following alias to run pip3.7 everytime I use pip command:


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/pip

while 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/pip3

I 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.

  • type -a pip will show you which one bash runs. type -a pip3.7 will show you which one your alias runs. – waltinator Oct 12 '18 at 20:12
  • I think this will answer your question: Why not use “which”? What to use then? - Unix & Linux – wjandrea Oct 12 '18 at 20:39
  • @waltinator But does alias override bash? type -a pip - pip is aliased to "pip3.7" pip is /home/uname/.local/bin/pip. And then: type -a pip3.7 - pip3.7 is /home/uname/.local/bin/pip3.7 pip3.7 is /usr/local/bin/pip3.7 – glc78 Oct 12 '18 at 21:02

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
$ 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)
  • I have the same situation as the example, except that also deleting the alias I have the following: pip -V pip 18.1 from /home/g-luca/.local/lib/python3.7/site-packages/pip (python 3.7) – glc78 Oct 12 '18 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.