Python is an object-oriented, high-level, interpreted programming language. Guido van Rossum created it. The programming language first appeared in the year 1991. At the time of writing, v3.10.2 is the latest stable release. In this article we discuss how to install Python 3.10.2 in Ubuntu 22.04 release.
It is one of the most popular programming languages.
As of now, v3.9.9 is available through standard Ubuntu repository. If we install v3.10.2 in our system then, we have the option to keep both the available versions. This article is all about installing v3.10.2 of Python and keeping that alongside already installed version of Python.
To check for the Python version installed, open a terminal and issue the following –
python3 -V
For us, it returned with –
Python 3.9.9
Note: Following operations would require you to have superuser privileges. In case you don’t have one, we advise you to contact your System Administrator for assistance.
Install Python 3.10.2 in Ubuntu 22.04
First, we have to download the relevant package file (.tar.xz) from the official website of Python. On the homepage, you will see Downloads drop-down menu. Therein, All releases and Python 3.xx.x button. For us, the version was 3.10.2.
It would download the package file – Python-3.10.2.tar.xz
We need to extract it using tar command-line utility. It would create Python-3.10.2/ in the current directory. Use cd command-line utility to navigate inside the directory.
cd Python-3.10.2/
and issue following commands –
./configure make make test
Next, to install Python v3.10.2 along side v3.9.9 –
sudo make altinstall
At this point, we got an error –
ModuleNotFoundError: No module named 'zlib'
To resolve, we had to install package –
sudo apt install zlib1g-dev
If you didn’t get an error related to zlig1g-dev and successfully installed Python. Then, its fine. Otherwise, you would have to again issue the command after installing zlib1g-dev –
sudo make altinstall
In conclusion, we have discussed how to install Python 3.10.2 in Ubuntu 22.04 release. This will install Python v3.10.2 along side Python v3.9.9.