tl;dr: Download an installer from https://www.python.org/downloads/macos/ (or read on for a link to each major version)
There are many ways to install Python on a Mac. In my opinion, most of them are unnecessarily complicated and error prone. To list a few complaints:
- Homebrew might not support all the versions of Python you need to install for local development. There have also been issues with having multiple Python versions installed side-by-side.
pyenvhas the opposite problem. It gives you almost infinite control over the version of Python you have installed and gives you a way to switch between them, but for the majority of use cases, this is overkill. I’ve almost never needed to test code against different minor releases of Python. Usually, some reasonably-recent version of each major Python release is sufficient. It is certainly unnecessary for developers getting started with Python.
- Both of these installation methods also risk breaking as Homebrew updates Python or other related packages in the future.
Instead, I prefer to install Python on Macs using the downloadable installers from Python.org. The majority of the time, they just work.
This page includes links to the last available installer on Python.org for each major Python release. Since Python does not release downloadable installers after regular maintenance ends, finding the right link can take a minute.
|Most Recent Download Page
|https://www.python.org/downloads/release/python-3810/ (first version to support Apple Silicon)
|3.10 and later
For a given release:
Scroll down to the “Files” section on the page
Find and download the “macOS 64-bit installer”
- For 3.8 and later, you’ll be given a choice between an “Intel” and “universal2” installer. If you’re using Apple Silicon, you’ll want to choose the “universal2” installer.
Find the installer in your Downloads folder, open it, and run through the installation steps.
Open a terminal and verify that your shell can find the Python version you just installed. For Pythons installed with these installers, the binaries will end up in
/usr/local/bin. For example:
% which python3.8 /usr/local/bin/python3.8
Good luck, and happy programming!
The above list was compiled by scanning https://www.python.org/downloads/macos/ for the most recent release with Mac installers.