How To Mac

How to Install Python on Mac

Written by John

Python is a general-purpose interpreted, object-oriented, interactive, and high-level programming language. It was created by Guido van Rossum in the late 1980s and first released in 1991. Python 2.0 was released in 2000, introducing new features including a garbage collection system and list comprehensions. In 2008, Python 3.0 was released and was completely backward-incompatible. However, many of the important features have been backported and are compatible with version 2.7.

Python 3 is highly readable and uses many English keywords for better understanding. It uses fewer punctuations and has fewer syntactical constructions. It is an easy language to learn for new programmers. Python 3 supports functional and structured programming methods, automatic garbage collection, and dynamic-type checking. It is easily integrated with other programming languages such as C, C++, and Java.

Python 3 as a beginner’s language is interactive and easy to read. The source code is easy to maintain. Python libraries are portable and can run with the same interface on a wide range of platforms such as Windows, Macintosh, and UNIX. Python is scalable and has better support for large programs. It supports the creation of GUI applications that can be ported to libraries and windows systems such as UNIX X Window System and Windows MFC. Python is extendable with low-level modules that enable programmers to make their tools more efficient through customization. It also has interfaces to all major databases.

Install Python with Homebrew?

Homebrew is a package manager that makes it easier to install software on macOS and Linux. You can save a lot of time finding and installing the right software for your operating system, by using a software package manager. Homebrew requires a compiler to install packages in macOS. You can install Xcode to get the compiler. Xcode is an integrated development environment (IDE) for macOS and has the tools needed to develop software for Apple operating systems.

When installing software using Homebrew, the package manager identifies and installs the right software for your particular system, depending on your specific setup. App installs can take anywhere between a few seconds and several minutes to complete.

The Problem With Python 2.7

Python 2.7 comes pre-installed on Mac. However, the version is deprecated and has not been maintained after January 1, 2020. Hence, if you use Python 2.7 to build projects and any security issues arise with any of the packages you’re using, it would compromise your projects since nobody will be working on fixing your issues. It is essential to switch to Python 3 for a better experience and continued support.

The next version of macOS will be called Ventura and it won't have a Python 2.7 in Terminal like before or older versions do.

How to Install Python 3 on Mac

We will install Python 3 on Mac and set up everything so that it becomes the default instead of Python 2 that is already pre-installed.

Step 1: Go to Applications > Utilities > Terminal.

Step 2: In Terminal, type: python3. Xcode Command Line Developer Tools should be the first result to be returned. Click on it and click the Install button. Xcode takes some time to download. The command-line tools should be installed in a few minutes.

Install python3 with Command Line Tools

Now, we need to get Python 3 from a package manager. There are two software package managers for macOS — MacPorts and Homebrew. We will use Homebrew to install Python 3 as it is more user-friendly. Homebrew requires a compiler to install packages.

Step 3: Now, we have to install Homebrew. Go to On the homepage, you should have the command to install Homebrew. Copy it, switch back to Terminal, paste the command, and press return.

Install Homebrew on macOS Monterey

The installation will begin and Homebrew will ask permission to create new directories. Press return and type your password to grant permission. The installation process will be completed and Homebrew will be installed on your Mac.

Replace PATH in Configuration file (for M1/M2 Macs):
If you have an Intel Mac, then skip this step. But if your computer is Apple Silicon make sure to replace PATH in configuration file before running Brew.

The installation process for brew will happen in two different locations depending on your Mac. If you're installing it onto an Intel Mac, then the program is installed at '/usr/local/bin' while for ARM-based devices like MacBook Air M2 there's a separate folder called 'opt/homebrew/bin'.

You can use the following commands to set your PATH in Terminal Configuration file, one important thing to remember is that you'll need a .zprofile file if zsh has been selected as Apple's default shell.

cd ~/
touch .zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Create zprofile to run Brew on M1 M2 Mac

Step 4: To install Python 3, run the command: brew install python

Install Python 3.9 on macOS Monterey

How to Properly Set Up Python 3 on macOS Ventura and Monterey

Python 3 is installed on your macOS. However, you need to properly set it up to make it the default instead of Python 2. Follow the steps below to properly set up Python 3 on your Mac.

The two versions of Python on macOS are 3.9.2 and 3.10.8; one was installed by XCode Command Line Tools, while the other came via Brew. The first step is determining where your Python files are located. This can be done by opening up terminal and typing "which python3" and "brew info python3".

Python 3 folder PATH

To use Python 3.10.8, we will be editing our .zprofile file and changing the PATH in order for it to point at /usr/local/bin/python3 instead of python (which is what currently exists on this terminal).You can use the following commands: 

cd ~/
touch .zprofile (no need to use this command if you already created .zprofile)
echo 'alias python=/usr/local/bin/python3' >> $HOME/.zprofile

Replace Python3 with Python in zprofile

Next, you need to close and reopen Terminal. Check the version of Python by entering: python. This will confirm that Python 3 is the default version on your macOS Monterey and macOS Ventura.

New Python 3.10.8 on Mac

Python 3 allows you to take full advantage of one of the most widely used programming languages on the web. By following the steps above, you can make it the default version to run on Mac.


  • Thanks- Step 5 has a capital Source, but the image shows the proper lower case source.

    After the initial install of developer tools, python3 runs a 3.9 version; brew install python is currently installing 3.10, which runs as python3.10
    Thanks for the help!

Leave a Comment