macOS: Installing Python 3.x
There are several ways to install and manage Python on your machine. The simplest option is sourcing Python directly from the Python Software Foundation website. If you are new to Python and unfamiliar with package managers this install guide is written for you.
⚠️ If you are an Anaconda and/or Homebrew user, this install guide is not for you. The teaching team assumes that you are familiar with managing your Python installation utilizing a package management system invoked from a command line interface (CLI) such as Terminal.app or iTerm2. As is noted below we recommend that you run the latest stable version of Python supported by Ananconda and/or Homebrew.
1.0 Check for previous install
First, confirm whether or not Python is installed on your machine.1.1 Locate and open Terminal.app
Mac includes a terminal emulator called Terminal.app
that you can use to interact with the
operating system by issuing text-based shell commands. Use Finder
to locate Terminal.app
in the
directory Applications/Utilities/
. You can traverse the directory structure by clicking on each
folder or use the keyboard shortcut: (Command + Shift + U
).
💡 I recommend dragging the Terminal.app
icon to your dock in order to simplify accessing
Terminal.app
in future (you will be using it frequently).
Double-click the Terminal.app icon to open it. The terminal opens with a white background. If you want to change the background color see the following StackExchange thread.
❗ To close a terminal session type ’exit’ at the prompt and then press Return key.
1.2 Check if Python 3.x is installed
At the prompt, type the following line python3 --version
and then press the Return key:
$ python3 --version
Python 3.13.1
❗ Note that Mac comes with Python 2.7.x pre-installed. Python 2.x is considered retired and no longer supported as of 1 January 2020.
1.3 Running older versions of Python
Note that Python 3.9.6 is most likely included in your macOS install. This version is now several generations old and lacks a number of enhancements, including performance improvements, provided by more recent releases. We encourage you to install the latest release of Python 3.x.
If Python 3.11.x or 3.12.x is installed on your machine (where “.x” equals an incremental version number, e.g., 3.13.1) you do not need to upgrade to the latest stable verison of Python for this class. That said, we encourage you to run the latest stable release in order to leverage the latest improvements to the language.
2.0 Download and install Python 3.x
Once you’ve checked your machines for previous Python installs, visit the Python Software Foundation website and download the lastest stable Python 3.x release.2.1 Download Python 3.x
Hover over “Downloads” on the blue menu bar. Your macOS operating system version should have been detected on the page load and the link to the Python 3.13.1 release package displayed as a grey button. Click the grey button to download the install package.
2.2 Install Python 3.x
Once downloaded to your Downloads
directory, double-click the Python 3.13.1 *.pkg
file. Click the
“Continue” button and proceed with the installation. I recommend installing Python 3 in the default
Applications
directory.
2.3 Confirm installation
Once installed return to the Terminal.app
and confirm that Python 3 has been installed successfully.
$ python3 --version
Python 3.13.1
3.0 Source code editor
The Python installer also installs Python’s Integrated Development and Learning Environment (IDLE).
The IDLE
app provides a multi-window text editor, interactive shell window, search/replace, and
debugger. It is one of several text editors that you can use to write and test Python code. However,
we do not use it.
Instead, we use Microsoft’s popular (and free) Visual Studio Code which serves as the default source code editor for this course. See the relevant companion guide for installation instructions.