Python is a versatile and powerful programming language with widespread applications. As a Mac user, you may be interested in installing and running Python on your device to run certain applications or to begin creating and running your own Python scripts.

While an older version of Python does come preinstalled with some versions of macOS, you’ll probably need to install a newer version. To help you, we’ll explain how to install and run Python on your Mac below.

Table of Contents
    How to Install and Run Python on Your Mac image 1

    Do I Need to Install Python on macOS?

    As a Mac user, you might wonder if you need to install Python on your system. The answer is probably yes—for two important reasons.

    The first reason is compatibility. If you’re running macOS Monterey 12.2 or earlier, you probably have Python 2.7 pre-installed. However, Python 3 is the latest version and has significantly improved features compared to Python 2.7. Python 2.7 is also old, no longer officially supported, and less secure than Python 3.

    The second reason is much simpler—Python might not be installed at all. If you’re running macOS Monterey 12.3 or later, you’ll find that Apple has removed Python 2.7 from the installation completely. You’ll need to install Python again to continue.

    To check the Python version on your Mac, open the Terminal application and type python –version. If it doesn’t run, or it lists 2.7 as the version, you should consider upgrading to a newer Python release.

    You can use Python’s official installer, found on their website, or use a package manager like Homebrew to install the latest version of Python. To check if Python 3 is already installed, type python3 –version in the Terminal instead.

    How to Install and Run Python on Your Mac image 2

    How to Install Python on macOS Using the Official Installer

    The quickest way to install Python on macOS (whether the older 2.7 release or the newer Python 3 release) is to use the official installer from the Python website. To install Python this way, follow these steps.

    1. Start by opening your web browser and visiting the Python download page. The website will automatically detect your operating system and display a download button which you can press to download the latest version of the Python installer for your Mac. If it doesn’t, click the macOS link and choose the latest Python release.
    How to Install and Run Python on Your Mac image 3
    1. After downloading the installer package, open Finder, locate it in your downloads folder and double-click the file to begin the installation process.
    2. Press Continue and follow the on-screen instructions to configure and install Python. You can choose between the default installation settings or customize them according to your preferences.
    How to Install and Run Python on Your Mac image 4
    1. The installation process may take a few minutes. Once complete, you can verify the installation by opening the Terminal application on your Mac and running the python –version or python3 –version commands. The Terminal should show the correct version number of your Python installation.
    How to Install and Run Python on Your Mac image 2
    1. To run Python, type python or python3 in the Terminal and press enter. This will allow you to type Python code directly into the Python terminal.
    How to Install and Run Python on Your Mac image 6
    1. To exit, type exit() and press enter.

    At this point, you’ve successfully installed Python on your Mac. You can now run your own Python scripts or applications or create your own. If you want, you can also install additional Python packages using the Python PIP installer.

    How to Install Python on macOS Using Homebrew

    An alternative method for installing Python on a Mac is to use Homebrew. Homebrew is a third-party package manager for macOS that allows you to quickly install applications using the terminal, replicating a Linux-style experience for your Mac.

    Ironically, Homebrew requires Python to be installed to work correctly, so installing Homebrew should ensure that a working Python installation is available, too.

    To install Python on your Mac using Homebrew, follow these steps.

    1. First, open your Terminal application and check if Homebrew is already installed by running this command: brew –version. If Homebrew is already installed, you’ll see its version number. If not, continue to the next step.
    How to Install and Run Python on Your Mac image 7
    1. To install Homebrew, run this command in the Terminal: /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”. The script will explain what changes it will make and prompt you to approve them before the installation begins.
    How to Install and Run Python on Your Mac image 8
    1. After Homebrew is installed, you can use it to install Python. To do this, type brew install python (or brew install python3) into the Terminal and press the enter key. This will install the latest version of Python available.
    How to Install and Run Python on Your Mac image 9
    1. Afterward, run brew link python (or brew link python@3.XX (replacing XX with the correct version number) and restart the Terminal app to ensure the application works correctly.
    How to Install and Run Python on Your Mac image 10
    1. Once Python is installed, you can check the version by running the python –version command in the Terminal (or python3 –version instead). This will show the installed version of Python 3.
    How to Install and Run Python on Your Mac image 11
    1. To run Python, type python or python3 from the Terminal to launch the Python terminal. The version number will appear after the command runs to allow you to identify which version you’re loading.
    How to Install and Run Python on Your Mac image 12
    1. Type exit() and press enter to exit at any point.

    At this point, Python should be installed correctly, and you can begin to use it. Remember to keep your Homebrew and Python installations up-to-date by periodically running brew update and upgrade from the Terminal app.

    Programming With Python on a Mac

    Installing and running Python on your Mac is straightforward using the steps above. While older macOS releases might have Python 2.7 installed, installing a newer Python 3 release on your Mac is better.

    Ready to become a programmer? If you’re a Python beginner, you can run python from the Terminal and start practicing today.

    If you run into any problems running your own third-party apps, don’t forget to allow your Mac to run unverified apps next.