Python Concepts/Introduction and Setup/MacOS Installation

These instructions will help you install Python on a MacOS machine, and is part of the ../ lesson.

Checking for an Existing Python Installation
Many versions of MacOS come bundled with Python installed, but it is usually an obsolete Python 2 release. That is why you should take extra care following the steps below to determine if Python is already installed on your machine. Open the terminal app and type. Compare your output to the cases outlined below:

If the command outputs "Python 3.x" (version number >= 3.0):
Example: Python 3.10.5 You already have a recent version of Python installed! Return to the lesson.

If you get "command not found" or similar:
Example: zsh: command not found: python You don't have Python installed. Continue to Installation.

If the command outputs "Python 2.x" (version number < 3.0):
Example: Python 2.7.18 This is where things get complicated. See, you have Python 2 installed, but that's an obsolete version that is no longer supported. Try typing  instead. If that gives you a version above 3.0, return to the lesson. If not, install Python as normal below.

Installing Homebrew
MacOS, unlike most Linux distributions, has no official package manager built-in. Luckily, you can install a very popular one called Homebrew, which is how you will obtain Python and keep it up to date. Run the following command to install Homebrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

The command will walk you through the installation process. Pay close attention to additional instructions it may provide you. Type your password if prompted for it. After you install Homebrew, restart your computer and proceed to the next section.

Installing Python
After you have Homebrew installed, installing Python is only one command away! Open terminal and type: brew install python3 This may take one or two minutes depending on your machine. After the command completes, verify the installation was successful by running  (or  ). Congratulations, you have installed Python!

Return to ../