Installing Python on macOS
This guide will help you install Python on macOS. Python on macOS can get messy. If you run into any issues while running the instructions detailed below, please post to Piazza.
(Optional) Update macOS
Prior to macOS 12.3, macOS came with Python 2.7. This version is nearly 13 years old and not suitable for development. Therefore, Apple removed it from macOS in 12.3.
If possible, you can update your computer to any version of macOS after 12.2, and the installer will delete Python. This is not necessary, but if your machine is new enough that 12.3+ is supported and you don't have any concerns about it effecting your battery health, it is easier if you update your computer.
Verify you don't already have python3 installed
- Open Finder > Applications > Terminal
- Run
python3 --version
. You should get something along the lines ofzsh: command not found: python3
. Otherwise, you havepython3
installed.
If you have python installed from the developer website, you are all set. If you have python3 installed through Homebrew, we recommend you install and use python from the developer website. To tell the difference, run whereis python3
in Terminal. If you get /usr/bin/python3
, you're all set.
Otherwise, we recommend you follow the below installation directions.
Installing
- Go to https://www.python.org/downloads/
- You should see "Download the latest version for macOS", followed by a button labeled
Download Python 3.x
. Click the button to start the download. If the website does not automatically detect you are running macOS, selectmacOS
under "Looking for Python with a different OS?".
- Once the download is finished, run the
.pkg
to run the installer. - Run through the installer, and click
Install
. - Open Finder > Applications > Python 3.x.
- Right-click on
Update Shell Profile.command
, and click open. This will run a process in Terminal that lets you runpython3
from your command line. - Restart Terminal, type
python3
, and pressEnter
.
At this point, you should see something like the following screen:
To exit, type quit()
and press Enter
.