How to Update Python on Mac Terminal

If you’re a frequent user or developer of Python scripts, you definitely know how powerful it is. You also know the importance of keeping your Mac updated with the latest version so that you can take advantage of everything it has to offer.

Most of us who use and create Python scripts spend a great deal of our time in Mac Terminal so it only makes sense that you would want to be able to update your version of Python from the Terminal application. It’s easy to do and I will show you how to do it here.

My name is Eric and I have been a Software Engineer and Configuration Manager for over 20 years. Deploying and installing new versions of software is a key function in my job and updating Python is fairly straightforward and something anyone can do.

Follow me through this article if you would like to learn how to update Python from Mac Terminal. We will also cover how to update it from your desktop. Once you learn, you can easily keep your version of Python up to date.

So keep reading to get started!

How to Update Python on Mac with Homebrew

The easiest way to update Python using Mac Terminal is with Homebrew. Follow the steps below to ensure you keep your version of Python up to date.

Step 1: Open Mac Terminal

You can open Mac Terminal either from your dock or Launchpad. By default, it is nested in the “Other” folder in Launchpad.

Step 2: Install Homebrew

If you already have Homebrew installed, you can skip to the next step. If you have never installed it on your Mac then you will need to install it. Run the command below to install Homebrew. Note: the command shown is all one line.

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”

You’ll be asked for your admin account password. This should be the password you use to log in to your Mac. Then you will see lots of output on the screen. 

Keep an eye on the screen as you may need to hit Return/Enter to continue and possibly enter your password again. The entire installation will take a few minutes.

Step 3: Install the Latest Version of Python

In the Terminal application, type the command below to install the latest version of Python.

brew install Python

Once completed the latest version of Python will be installed.

Step 4: Invoke the New Version with the python3 Command

The latest version of Python is installed as python3. To use the new version you will want to use the command python3. 

The old version of Python that came with your Mac will still be there and can be used with the original python command. There are ways to change this but I would recommend leaving it because there are instances where your macOS may need the original version.

How to Update Python on Mac using Python Installer 

If you’re not comfortable installing Python from Mac Terminal using the commands shown above, you can install it from your desktop using the Python installer. The steps below will show you how to do this.

Step 1: Open your Browser from the Mac Desktop

Open your favorite internet browser before moving on to step 2. 

Step 2: Download the Installer from Python.org

Once you get to Python.org, click on the Downloads menu. It will automatically detect your macOS and provide you with a button to download the latest version.

Step 3: Double-Click on the Python Install Package to Begin Installation

The installer will startup. Click on the continue button.

Step 4: Follow the On-Screen Instructions

After clicking “Continue,” you will need to follow the on-screen instructions. It will step you through the license agreement, and give you options as to where to install it and the type of installation. You can accept all the default options or change them if you would like to do so.

Step 5: Open IDLE to Verify it was Installed Correctly

Once the installation completes, open the IDLE applications to verify the version and that it works.

How to Determine the Python Version on Your Mac

If you want to see your current version of Python, you can do so by typing python or python3 with the –version parameter as shown below. Remember to run the version of Python that you are looking for (python or python3).

python –version

or

python3 –version

Once the command is run, you will see an output showing the current version.

Conclusion

Updating Python on your Mac is fairly simple and can be done by anyone. It can be done using Mac Terminal or through the desktop installation as we have seen above. Both methods work well so use the one you are most comfortable with.

As usual, let me know if you have any questions or comments. I would love to hear from you!

Leave a Reply

Your email address will not be published.