As a Python developer, I have various installations of
ipython at various versions in various
virtualenvs' paths, and so it is important to know which one I am running. Hence the
$PATH is always changed when I change
virtualenv, and this would a typical value for
$ echo $PATH /Users/jab/.virtualenvs/tools/bin:/Users/jab/bin:/Users/jab/src/git/hub/jab/bin:/usr/local/gnu:/bin:/usr/local/bin:/usr/bin
The important detail in that is that the first entry is "
/Users/jab/.virtualenvs/tools/bin", and that the file
/Users/jab/.virtualenvs/tools/bin/ipython does exist:
$ ls -l /Users/jab/.virtualenvs/tools/bin/ipython -rwxr-xr-x 1 jab staff 252 May 11 15:18 /Users/jab/.virtualenvs/tools/bin/ipython
which says that that file will be run as the "
$ ipython" command
$ which ipython /Users/jab/.virtualenvs/tools/bin/ipython $ $(which ipython) -c "import sys; print(sys.executable)" /Users/jab/.virtualenvs/tools/bin/python
However, that is not actually the case, and
/usr/local/bin/ipython is run instead
$ ipython -c "import sys; print(sys.executable)" /usr/local/bin/python3
Can someone explain why
bash is ignoring my
$PATH and using the "wrong" executable? And what do I need to change (in my bashrc, or on my system (
macOS 10.12.3)) so that executables are chosen by bash in the order determined by my
Note: This is not a duplicate Bash is not finding a program even though it's on my path, because that asks how PATH works to find any program, whereas this question is anout why the wrong program is found.