DEV Community

Cover image for Install latest Python version on any Debian Based Linux distro.
Ivaylo Ivanov
Ivaylo Ivanov

Posted on • Updated on

Install latest Python version on any Debian Based Linux distro.

Hi guys, today I am going to show you how to install the latest Python3 version (at the time of writing this post the current version is 3.10.2). In my example, I am going to use Ubuntu 20.04. Without further due, let's hop into the topic.

1. Update your Linux distro.

Before installing python3, make sure to update your Linux system.

sudo apt update && sudo apt -y upgrade
Enter fullscreen mode Exit fullscreen mode

2. Adding Python archive to the apt manager.

After you have your system updated it is time to add the python archive to the apt manager. To do that we are going to need the required dependencies for adding custom archives. We are going to need software-properties-common

sudo apt install software-properties-common -y
Enter fullscreen mode Exit fullscreen mode

After you have installed the required dependency, we are going to add the Personal Package Archive (PPA). You can read about PPA here.

sudo add-apt-repository ppa:deadsnakes/ppa
Enter fullscreen mode Exit fullscreen mode

You will be prompted with a long text like this:
PPA python text

Just hit enter and python is going to be added.
Now you have added successfully the python archive to the apt
package manager and you can install the latest version using apt.

3. Installing the latest python version.

Now you have access to the python official versions. To install the latest just look up on the official python website the latest version, and install it like that:

sudo apt install python3.10
Enter fullscreen mode Exit fullscreen mode

Congrats you have installed the latest python on your Linux distro.
To check the installation, just type the python you have installed and add after it --version.

python3.10 --version
Enter fullscreen mode Exit fullscreen mode

Python version test

If you have any questions, leave a comment and I will answer as soon as possible.

Top comments (2)

Collapse
 
anonyco profile image
Jack Giffin • Edited

apt is only available on Debian derivatives. This is certainly not "any distro."

Collapse
 
jugmac00 profile image
Jürgen Gmach

Please note that the deadsnakes PPA is only tried and tested for LTS releases of Ubuntu, not for interims releases, not for Debian, and especially not for other distributions.