Python Concepts/Introduction and Setup/MacOS Installation
Checking for an Existing Python Installation edit
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
If the command outputs "Python 3.x" (version number >= 3.0): edit
You already have a recent version of Python installed! Return to the lesson.
If you get "command not found" or similar: edit
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): edit
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
Either way, keep in mind that during the course, you will always need to use the
Installing Homebrew edit
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 edit
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
Return to Introduction and Setup
- "Installing Python 3 on Mac OS X". Python Documentation. Python Software Foundation. Retrieved 2022-06-26.