Python is a popular programming language that has a very active community and upgraded regularly. Currently, Python has two main versions Python2 and Python3. There are a lot of minor release versions where the latest Python3 version is 3.9.1. In order to use this version, the Python installation should be upgraded from older versions. In this tutorial, we will examine how to upgrade Python into a specific or latest version.
Print Python Version
Before upgrade displaying current Python installation version can be helpfull. Current python installation can be printed with the –version option in the command line interface. The following command can be executed in Windows PowerShell, MS-DOS, Linux Terminal, Bash, MacOSX Terminal.
python --version
The currently installed Python version is listed like below.
3.9.0
In some cases specifying the major python version to get version information is better way.
python3 --version
3.9.0
Upgrade Python For Windows
Different Python versions for Windows are provided via the python.org web site. The latest version for the current installation can be downloaded and upgraded. The following page provides both Python2 and Python3 installers for the latest and previous versions. Simply select the version you want to upgrade and download the installer.
https://www.python.org/downloads/windows/

When the download is completed double click to the installer. We will see the following screen which informs that the current Python installer upgrade to the Python 3.9.1 (64-bit). We will simply click to the “Upgrade Now” button. This installation replace our existing installation without changing settings. Alternatively you can click to customize the installation and change some settings.

During the upgrade we will see the following Setup Progress screen.

Upgrade Python For Linux
Upgrading Python in Linux is very easy with the package managers like apt-get, apt, yum, dnf etc. Actually generic update and upgrade commands for these package managers upgrades the PYthon into the most recent versions.
Upgrade Python for Debian, Mint, Kali, Ubuntu with apt-get:
sudo apt-get update && sudo apt-get dist-upgrade
Upgrade Python for Debian, Mint, Kali, Ubuntu with apt:
sudo apt update && sudo apt dist-upgrade
Upgrade Python for CentOS, RHEL, Fedora with yum:
sudo yum update
Upgrade Python for CentOS, RHEL, Fedora with dnf:
sudo dnf update
Alternatively we can only upgrade Python into the recent version without upgrading other packages like below.
Upgrade Python for Debian, Mint, Kali, Ubuntu with apt-get:
sudo apt-get update && sudo apt-get dist-upgrade python
Upgrade Python for Debian, Mint, Kali, Ubuntu with apt:
sudo apt update && sudo apt dist-upgrade python
Upgrade Python for CentOS, RHEL, Fedora with yum:
sudo yum update python
Upgrade Python for CentOS, RHEL, Fedora with dnf:
sudo dnf update python