How To Update Python On Mac

Python is a versatile and widely-used programming language that comes pre-installed on macOS. However, the pre-installed version of Python on Mac is usually older and may not have the latest features and bug fixes. In this blog post, we will walk you through the process of updating Python to the latest version on your Mac.

Step 1: Check your current Python version

Before you update Python, it is important to know the version you are currently using. To check your Python version, open the Terminal app on your Mac and type the following command:

python –version

This command will display the current Python version installed on your system. For example:

Python 2.7.16

Step 2: Install Homebrew

Homebrew is a package manager for macOS that makes it easy to install and manage software. We will use Homebrew to install the latest version of Python.

To install Homebrew, open the Terminal and paste the following command:

/bin/bash -c “$(curl -fsSL”

Press Enter and follow the prompts to complete the installation.

Step 3: Update and install Python with Homebrew

Now that you have Homebrew installed, you can use it to update Python. First, update Homebrew to ensure you have access to the latest packages:

brew update

Next, install the latest version of Python using the following command:

brew install python

This will install the latest version of Python and its dependencies. Once the installation is complete, you can check your Python version again:

python3 –version

Note that we use python3 instead of python to refer to the newly installed Python. This is because macOS still uses the older version of Python as the default for system-level tasks, and we don’t want to interfere with those processes.

Step 4: Update your PATH (optional)

By default, when you run the python command in the Terminal, it will still point to the older, system-level version of Python. If you want to use the latest version of Python by default, you can update your PATH.

Open the Terminal and type the following command:

nano ~/.zshrc

This will open your shell configuration file in the nano text editor. Add the following line at the end of the file:

export PATH=”/usr/local/opt/[email protected]/bin:$PATH”

Make sure to replace “3.9” with the version number of the Python you just installed. Save the file and exit nano by pressing Ctrl + X, then Y, and then Enter.

Restart your Terminal, or type the following command to apply the changes:

source ~/.zshrc

Now, when you run the python command, it should point to the latest version of Python.


That’s it! You have successfully updated Python on your Mac. Now you can enjoy the latest features and bug fixes in your Python development projects. Remember to periodically update your Python installation to stay up-to-date with the latest improvements.