The "python" CLI executable seems to ignore path hierarchy I have the following strange situation on my (freshly installed El Capitan, otherwise empty) Mac.

I noticed that /usr/bin/python defaults to python 2.7 (still), and the new SIP security system "protects" me from replacing it with a symlink to point to python3 (which I installed in /usr/local/bin). I noticed that /usr/local/bin shows up first on the path:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin


So I thought great, I'll just add a symlink in /usr/local/bin called python and point it to python3. 

$ ls -al /usr/local/bin
...
lrwxr-xr-x   ... python -&gt; /usr/local/bin/python3
lrwxr-xr-x   ... python3 -&gt; ../Cellar/python3/3.5.0/bin/python3


And this is reflected by which

$ which python
/usr/local/bin/python


But when I actually use it, it goes back to the native python2.7

$ python --version
Python 2.7.10


What gives? Is OS X tinkering with my $PATH and not telling me? What steps can I take to ensure I know what command is actually going to be run?
Try closing your terminal window, and making a new one. The shell only actually checks where commands are located on launch, and doesn't check again if it thinks it knows where the command is located. It's a performance boost in scripts, so generally a good idea.