How do i upgrade to python 3?

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 do i upgrade to python 3?

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:

  • Windows 10
  • Ubuntu 20.04
  • CentOS 8

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.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

3. Click the Get button to start the installation.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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

How do i upgrade to python 3?

4. Once the installation is complete, select Close.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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 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.

How do i upgrade to python 3?

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

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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.

How do i upgrade to python 3?

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.

How can I update my Python version?

Follow the below steps to update your python version:.
Step 1: Go to Python's official site..
Step 2: Click on the Downloads tab..
Step 3: Download the version you need to upgrade to based on your system specifications(ie, 32-bit or 64-bit). ... .
Step 4: Click on the installer and it will begin the installation..

How do I install the latest version of Python 3?

Installing Python 3 on Linux.
$ python3 --version. ... .
$ sudo apt-get update $ sudo apt-get install python3.6. ... .
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update $ sudo apt-get install python3.8. ... .
$ sudo dnf install python3..

How do I install Python 3 on Windows 10?

3 at the time of writing this article..
Step 1: Download the Python Installer binaries. Open the official Python website in your web browser. ... .
Step 2: Run the Executable Installer. Once the installer is downloaded, run the Python installer. ... .
Step 3: Add Python to environmental variables. ... .
Step 4: Verify the Python Installation..

How do I update Python to latest version of Windows?

To update Python in Windows using the Python installer, follow the below-mentioned steps carefully..
Step 1: Check Python Version. Firstly, check the current Python version using Command Prompt: ... .
Step 2: Download Python Installer. ... .
Step 3: Execute Python Installer. ... .
Step 4: Install Python. ... .
Step 5: Check Python Version..