This one will solve all your problems not only on Mac but to find it on Linux also ( & every basic shell).
TL;DR (you don't have to go through all the answer - just the 1st half).
LET'S GO
Run in terminal:
which python3
On Mac you should get:
/usr/local/bin/python3
WAIT!!! It's 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 is 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
Answer from Kohn1001 on Stack OverflowThis one will solve all your problems not only on Mac but to find it on Linux also ( & every basic shell).
TL;DR (you don't have to go through all the answer - just the 1st half).
LET'S GO
Run in terminal:
which python3
On Mac you should get:
/usr/local/bin/python3
WAIT!!! It's 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 is 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
I found the easiest way to locate it, you can use
which python
it will show something like this:
/usr/bin/python
Python's path on MacOS
Where do I find Python? - Apple Community
Python's path on MacOS
macos - PATH on Mac not working for Python - Unix & Linux Stack Exchange
How do I find the Python 3 path on macOS?
Why is my python3 path different from the one in the Applications folder?
Should I install pip packages into the system Python on macOS?
I moved from Windows to a MacBook yesterday (runs MacOS 14 Sonoma on Apple Silicon). I'm trying to get Python to work properly on my MacBook but I'm having a hard time figuring it out.
I'm being able to run Python from the terminal but it doesn't run from VSCode. From the terminal (ZSH) too, only python3 ran but not python. To get around that, I followed an online article and added a ~/.zshrc file. I added these two lines to it:
alias python="/usr/bin/env python3" alias pip="/usr/bin/env pip3"
I tried to install a Python package using pip but it hit me with a WARNING: The script normalizer is installed in '/Users/my_username/Library/Python/3.9/bin' which is not on PATH.
So till now I've understood that Python can be installed on Mac in 3 ways:
-
The default inbuilt Python that comes with Mac out of the box.
-
Python installed from the Python website via an installer.
-
Python installed via Homebrew.
I am not being able to figure out the paths where each of these methods install Python. Which method is better for installing? Homebrew or download from the website? And once I have Python using one of the options, how do I make sure that it is the one used over the system Python? If I override the system Python, will there be any issues? How do I get Python to run from VSCode?
My MacOS and command line knowledge is very rudimentary so please correct me if I've said something wrong.
I moved from Windows to a MacBook yesterday (runs MacOS 14 Sonoma on Apple Silicon). I'm trying to get Python to work properly on my MacBook but I'm having a hard time figuring it out.
I'm being able to run Python from the terminal but it doesn't run from VSCode. From the terminal (ZSH) too, only python3 ran but not python. To get around that, I followed an online article and added a ~/.zshrc file. I added these two lines to it:
alias python="/usr/bin/env python3" alias pip="/usr/bin/env pip3"
I tried to install a Python package using pip but it hit me with a WARNING: The script normalizer is installed in '/Users/my_username/Library/Python/3.9/bin' which is not on PATH.
So till now I've understood that Python can be installed on Mac in 3 ways:
-
The default inbuilt Python that comes with Mac out of the box.
-
Python installed from the Python website via an installer.
-
Python installed via Homebrew.
I am not being able to figure out the paths where each of these methods install Python. Which method is better for installing? Homebrew or download from the website? And once I have Python using one of the options, how do I make sure that it is the one used over the system Python? If I override the system Python, will there be any issues? How do I get Python to run from VSCode?
My MacOS and command line knowledge is very rudimentary so please correct me if I've said something wrong.
It's not clear how you installed python, but it could literally be installed anywhere on disk
If you want to find something use the find command
sudo find ~ -type f -name mdt
If that returns nothing, then mdt is not in your home folder
You can also find all directories with Python in the name
sudo find ~ -type d -iname '*python*'
There may not be a python3 folder. What you probably want is the python3 application. Type
which python3
and see what you get. In my case, I get the location of the python3 application. I also have the application python3.7. Once you find the location of these apps you can make sure the location is in your PATH.
Installing a python version does not create a python folder.