How to Upgrade Python to 3.9

August 5, 2021

Introduction

Every fresh Python release comes with bug fixes and new features. Python 3.9, the latest point release at the time of writing, comes with features such as improved time zone support, dictionary updates, and more flexible decorators.

This tutorial shows you how to upgrade Python to version 3.9 on all the major operating systems - Windows, macOS, and Linux.

How to Upgrade Python to 3.9

Prerequisites

  • Administrative rights on the operating system you are using.
  • Knowledge of which Python version is currently on your system. If you need help finding out the version of your Python installation, check out How to Check Python Version.

Note: If you are upgrading from a Python 2 release and do not have Python 3 installed, read our comprehensive guides on how to install it on:

Upgrading Python on Windows OS

To upgrade Python on Windows, download the installer or search for the app in the Microsoft Store.

Upgrade to Python 3 with the Installer

1. In your browser, visit the Python Releases for Windows section on the official Python website.

2. Click the Download Python button to download the installation file on your computer.

Downloading the newest version of Python for Windows

3. Next, run the Python installer. If you are upgrading from another point release of Python 3 (for example, 3.8.10), the installer suggests to install Python 3.9. Select Install Now to install Python with recommended options, or select Customize Installation to pick the install location and features.

Starting installation of Python 3 in Windows

If you already have an older version of the same Python release (for example, 3.9.1), the installer offers to upgrade your Python installation. Proceed by selecting Upgrade Now.

Starting the upgrade of Python 3 in Windows

4. When the installation finishes, check whether the new version of Python has been installed successfully. Open Windows PowerShell and type:

python3 --version

The output should show the latest version of Python, as in the image below.

Confirming the successful Python 3 installation in Windows

Install Python 3.9 from the Microsoft Store

If you want to use Python 3.9 to learn the basics or test some simple concepts, find and install the Python 3.9 app from the Microsoft Store.

1. Go to Microsoft Store and type Python in the search field.

2. Select Python 3.9 from the search results that appear.

Searching for Python 3 in Microsoft Store

3. Click the Get button to start the installation.

Starting Python 3.9 installation in Microsoft Store

Start the interactive Python 3.9 experience by finding the app in the Start Menu.

Upgrading Python on macOS

On macOS, Python can be installed, upgraded, and maintained using the command line interface or the GUI.

Upgrade Python using Homebrew

Install Python in the macOS terminal using the Homebrew package manager. If you do not have Homebrew, install it by typing the following script in the terminal:

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

Then, proceed with the steps:

1. Update Homebrew by running:

brew update

2. If you are upgrading from Python 2, install Python 3 with the command:

brew install python3

If you already have a version of Python 3 installed, upgrade the package with the brew upgrade command:

brew upgrade python3

Upgrade Python with the Installer

1. In your browser, navigate to the Python Releases for macOS page, on Python's official website.

2. Click the link to download the latest Python 3 release on your computer.

Downloading the Python installer for macOS from the official website

3. Run the installer. Go through the installation steps by clicking Continue, agreeing to the License, and confirming the installation location and type.

Starting a Python 3.9 installation in Mac OS using the installer

4. Once the installation is complete, select Close.

The installer confirms the successful installation of Python 3.9 on MacOS

5. Finally, confirm that the new Python version has been successfully installed by typing the following in terminal:

python3 --version

The output should display the latest version of Python.

Checking the Python version in macOS

Upgrading Python in Linux

This article uses Ubuntu and its APT package manager to upgrade Python. If you are using a different Linux distribution, replace the apt Linux command with the appropriate command featured for your package manager.

Warning: Many Linux systems have Python 2 installed as the system version. Removing Python 2 could cause a system error. If you are planning to install Python 3 on Linux, install it alongside Python 2 and invoke it with the python3 command.

1. Start by updating the repositories:

sudo apt update

2. Next, install Python 3.9 by running:

sudo apt install python3.9

When prompted, type Y to start the installation.

Installing Python 3.9 in Ubuntu with apt

3. Once Python installs, invoke the 3.9 version by running:

python3.9

4. However, checking the installation with the python3 --version command still returns the old version. To fix this, you need to create a list of update alternatives. First, add the old version to the list with the command:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.[old-version] 1

5. Now add the new version:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
Adding Python 3.9 to update alternatives

6. Next, type the following command to configure the priority status of the versions:

sudo update-alternatives --config python3

The output displays the available choices and their assigned number (in the example below, the numbers are 0, 1, 2). Type the number of the the version you wish to use and press Enter.

Configuring update-alternatives for Python 3 in Ubuntu

7. If you are not planning to use the old version of Python, remove the symlink that contained the previous Python 3 version with:

sudo rm /usr/bin/python3

8. Then, replace the symlink with the new version:

sudo ln -s python3.9 /usr/bin/python3

9. Now, check the default version:

python3 --version

The output should confirm the successful installation and setup of the latest available version.

Confirming the successful change of Python 3 version in Ubuntu

Why Should You Upgrade Python?

Since Python 3 was not a backward-compatible release, for a long time Python 2 remained the version of choice for those who wanted a stable development environment. Some services like Google App Engine did not support Python 3 for a long time.

However, given that the official support for the final Python 2.7 release has ended, upgrading to Python 3 is now strongly recommended. Python 3 is faster, and its syntax is more user-friendly.

If you already work with Python 3, upgrading to the latest point release gives you all the security updates and bug fixes.

Conclusion

After reading this tutorial, you should know how to upgrade your Python 3 version on Windows, macOS, and Linux. If you want to learn more about Python, read our article on Python data types.

Was this article helpful?
YesNo
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
How To Install Python 3 on Windows 10
April 2, 2019

Windows does not come with the Python programming language by default. However, you can install Python on your Windows server or local machine in just a few easy steps.
Read more
How To Install Flask
February 8, 2021

Flask is one of the most popular web application frameworks written in Python. This article explains how to install Flask in a virtual testing environment and create a simple Flask application.
Read more
How to Install Python 3 on Ubuntu 18.04 or 20.04
December 12, 2019

Python is a popular programming language often used to write scripts for operating systems. Learn how to install Python 3.8 on Ubuntu 18.04 or 20.04.
Read more
How to Install NumPy
May 8, 2020

NumPy (Numerical Python) is an open-source library for the Python programming language. It is used for scientific computing and working with arrays. Learn how to install it in this tutorial.
Read more