python location on mac osx

I found the easiest way to locate it, you can use

which python

it will show something like this:

/usr/bin/python


This one will solve all your problems not only on Mac but find your Python location on Linux also ( & every basic shell).

TL;DR (you don't have to go through all of it).
Just Run in terminal:

which python3

On Mac you should get:

/usr/local/bin/python3

WAIT!!! This is prob a symbolic link, how do you know? Run:

ls -al /usr/local/bin/python3 

and you'll get (if you've installed Python w/ Brew):

/usr/local/bin/python3 -> /usr/local/Cellar/python/3.6.4_4/bin/python3

which means that your

/usr/local/bin/python3 

is actually pointing to (the real location)

/usr/local/Cellar/python/3.6.4_4/bin/python3

That's it!

Longer version (optional): If for some reason, your

/usr/local/bin/python3 

is not pointing to the place you want, which in our case:

/usr/local/Cellar/python/3.6.4_4/bin/python3

just back it up (+cool trick to add .orig suffix to file):

cp /usr/local/bin/python3{,.orig} 

and run:

rm -rf /usr/local/bin/python3

now create a new symbolic link:

ln -s /usr/local/Cellar/python/3.6.4_4/bin/python3 /usr/local/bin/python3 

and now your

/usr/local/bin/python3

is pointing to

/usr/local/Cellar/python/3.6.4_4/bin/python3 

Check it out by running:

ls -al /usr/local/bin/python3

Tags:

Python

Macos