How to install the latest version of Python on Ubuntu and Debian?

How to install the latest version of Python on Ubuntu and Debian?

How to install the latest version of Python on Ubuntu and Debian?

As it is already well known by many technological users of free and open operating systems based on GNU/Linux, that is, Linux distributions such as Ubuntu, Debian, Arch, Red Hat, SUSE and many more; almost all of them come by default with some non-recent and stable version of Python installed. And of course, this often does not represent any problem or limitation for an office or administrative user at home, at school or in the office.

But, for medium or advanced technological users, such as Developers, System and Server Administrators, or self-taught technological curiosity in continuous testing and experimentation of applications and systems, this can represent certain problems and limitations. And although, many times, Some GNU/Linux Distros come with other, slightly more current versions of Python in their repositories. which are installed by default, they almost never offer the latest stable version and even less so, one in the development phase. Therefore, if anyone needs to use some of these aforementioned versions, they must resort to alternative means. And for this reason, today we will briefly show you the steps to follow in two alternative methods to achieve this goal. That is, to know how «install the latest version of Python on Ubuntu and Debian », or other derivatives of these.

about install python 3.9

But, before starting this publication with this useful and interesting tutorial to achieve «install the latest version of Python on Ubuntu and Debian », we recommend you explore a previous related post With the topic of Python, at the end of reading this:

about install python 3.9
Related article:
Python 3.9, how to install this version on Ubuntu 20.04

Tutorial to install Python on Ubuntu and Debian: Alternative methods

Tutorial to install Python on Ubuntu and Debian: Alternative methods

Methods to install the latest version of Python in Ubuntu and Debian

Installation via Deadsnakes PPA Repository

El Team Deadsnakes PPA Repository has proven, for a long time, to be a reliable supplier of packages of different python versions for Ubuntu, Debian and Distros derived from them. And to use it and install some versions of Python, the steps to follow currently are as follows:

  • Open a Terminal Emulator on Ubuntu or Derived
  • Run the following commands:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.13

If necessary, you can also install a full version by replacing the last command order with the following:

sudo apt-get install python3.13-full

While, if a Debian Distro or derivative of it is used, the additional thing to do will be edit the “sources.list” file required with the following command:

sudo nano /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-$VersionDebianDetectada.list

Then, change the word "bullseye" or "bookworm" or any other word corresponding to Debian and Derivatives with the words "jammy" or "focal" corresponding to Ubuntu. And thus obtain the following repository line (software source) as a result:

deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main

And so, continue with updating the package list again and the install python version 3, which was needed.

Installation via Python compilation from the official Repository

Installation via Python compilation from the official Repository

This is usually a slightly more complex and longer route, but also safer and more reliable, since it is literally download Python source files from the official Repository for compilation directly from our computer. And to make use of it and manage to install some versions of Python, the steps to follow currently are as follows:

Previous steps: installation of essential packages and libraries
sudo apt install wget build-essential
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
Main steps: Python compilation
cd /tmp/
wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0a3.tar.xz
tar -xf Python-3.13.0a3.tar.xz
cd Python-3.13.0a3/
./configure #Opcional en caso de ser necesario u error: --enable-optimizations
make -j2 #Reemplace el número por otro para indicar la cantidad de núcleos de CPU asignados a la tarea.
sudo make install #Preferiblemente con el parámetro altinstall para una instalación en paralelo.

If everything has gone well up to this point, that is, said downloaded version has been successfully compiled, all that remains is try installing the new version and the installation and use of the Python packages via “pip” manager. Which can be done using the following command orders:

python3.13 --version #Para chequear la versión nueva instalada.
python3 --version #Para chequear la versión previa instalada.
python3 -m pip --version #Para chequear la versión actual del Gestor PIP en la versión previa instalada de Python.
python3.13 -m pip --version #Para chequear la versión actual del Gestor PIP en la nueva versión instalada de Python.
python3.13 -m pip install --upgrade pip setuptools wheel #Instalación y actualización de paquetes Python esenciales.
sudo pip3.13 install --upgrade pip #Actualización a la última versión disponible del Gestor PIP.
sudo pip3.13 install speedtest-cli #Instalación del paquete Python SpeedTest CLI instalado con el Gestor PIP.
speedtest-cli #Ejecución del paquete Python SpeedTest CLI instalado con el Gestor PIP.
pyenv
Related article:
Pyenv: Install multiple versions of Python on your system

Summary 2023 - 2024

Summary

In short, if you are one of those technological, medium or advanced users (Dev, DevOps, SysAdmin, HelpDesk) or simply a curious self-taught technologist of free and open technologies in the year 2024, we hope that this practical and useful tutorial on how «install any recent version of Python on Ubuntu and Debian » allows you to solve any requirement regardless of whether it is an old and stable version or a modern and developing version. Additionally, if you know of any other more efficient alternative method, we invite you to mention it and briefly explain it in the comments for the study, testing and enjoyment of our entire Linuxera IT Community.

Lastly, remember to share this useful and fun post with others, and visit the beginning of our «site» in Spanish or other languages (adding 2 letters to the end of the URL, for example: ar, de, en, fr, ja, pt and ru, among many others). Additionally, we invite you to join our Official Telegram channel to read and share more news, guides and tutorials from our website. And also, the next Alternative Telegram channel to learn more about the Linuxverse in general.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.