Home  »  ArticlesGuidesLibrariesProgrammingTechnologyTools   »   How To Install Python 3.10 on Ubuntu 20.04 and Debian-Based Systems

How To Install Python 3.10 on Ubuntu 20.04 and Debian-Based Systems

By the end of this guide, you will be able to install Python 3.10 on Ubuntu and Debian-based Linux systems such as LinuxMint and more.

The motivation for this is that most of the Debian-based Linux distributions include older versions of Python in the official software repositories. Worse still, the Debian packages are not available for all distributions.

Note: If you are a user of CentOS 7 or CentOS 8 Linux systems then we have a similar tutorial for you otherwise, you can proceed with this tutorial.

Prepare the System

Log in to your Debian-based system with sudo privileged account access. Open the terminal and execute the commands below to update packages.

$ sudo apt update && sudo apt upgrade

Next, install the required prerequisite packages for the compilation of the Python source code.

$ sudo apt install wget build-essential libreadline-gplv2-dev libncursesw5-dev \
tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev libssl-dev libsqlite3-dev zlib1g-dev

Download and Install Python 3.10 Source

Visit the official Python site and download the latest stable release source package (Python 3.10.1)

$ wget https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz

Next, extract the archive file on your system

$ tar xzf Python-3.10.1.tgz

Enter into the extracted directory with cd command, then configure the Python source code before compiling it on your system.

$ cd Python-3.10.1
$ ./configure --enable-optimizations

Finally, run the make command to compile and install Python 3.10 on Ubuntu or any other Debian-based system. The altinstall use here prevents the compiler from overriding the default Python versions.

$ make altinstall

Confirm and Check Python Version

If the above make command runs without errors (normally it does) then it means you have successfully installed Python 3.10 on your Linux system. You can confirm the installation by checking the Python version using this command

$ python3.10 -V

Python 3.10.1

You can check pip for the Python version using the following command

$ pip3.10 -V

pip 21.2.3 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)

That’s It

In this micro tutorial, you learned how to compile and install Python 3.10 on Ubuntu, Debian, and LinuxMint systems using source code. Happy coding!

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.