Did you ever stumble across something like this:
Yes, this is strange, isn’t it? The PATH variable is set in the correct order (this is why ‘which’ finds the local Python). Googling about this behavior at first didn’t bring up any solution. But then I came across this now closed question on Stackoverflow.
So once you know what you are looking for Google reveals lots and lots of people having trouble with path hashing. Now, my solution was quite simple:
~ $ type python python is hashed (/usr/bin/python) ~ $ hash -t python /usr/bin/python ~ $ hash -d python ~ $ hash -t python -bash: hash: python: not found ~ $ which python /usr/local/bin/python ~ $ python --version Python 3.5.3
PS: To clear the complete bash path cache just use “hash -r”.