0

I'm on OSX and if I run python --version in a bash shell, I get this:

$ python --version
Python 3.7.3

But the which python command appears to be pointing to version 2.7.

$ which python
/usr/local/bin/python ls -al /usr/local/bin/python
lrwxr-xr-x  1 me  admin  36 11 Apr 22:28 /usr/local/bin/python -> ../Cellar/python@2/2.7.16/bin/python

I think this is because I have done alias python=python3: but why does which python not pick up the alias?

Richard
  • 3,463

1 Answers1

1

GNU which - is a utility that is used to find which executable (or alias or shell function) is executed when entered on the shell prompt.

Stolen from the which(1) man page:

The recommended way to use this utility is by adding an alias (C shell) or shell function (Bourne shell) for which like the following:

which () {
  (alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}
export -f which

Put this in your ~/.bashrc or whatever shell you use to enable this permanently.

Michael D.
  • 2,830