Python is a high-level programming language that is object-oriented. Python 3.10 is the most recent stable version for production envir...
Python is a high-level programming language that is object-oriented. Python 3.10 is the most recent stable version for production environments as of today. In the software repositories of most Debian-based Linux distributions, older versions of Python are available. Furthermore, not all Debian packages are accessible for all distributions. This lesson was tested on a Linux system running Ubuntu 20.04.
This guide will show you how to install Python 3.10 from source code on Ubuntu, Debian, and LinuxMint systems.
Prerequisites
To begin, log in with sudo privileged account access to your Debian-based machine. To update packages, open a terminal (CTRL+ALT+T) and run the commands below.
$ sudo apt update && sudo apt upgrade
Then, for Python source code compilation, install the essential packages.
$ sudo apt install wget build-essential libreadline-gplv2-dev libncursesw5-dev \
libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
Installing Python 3.10 with Source
Official Python source code can be downloaded from the official websites. Then compile and install the source code for your OS.
To install Python 3.10 on Debian computers, follow the procedures below:
1. You can either use the command below or download the Python 3.10 source archive from its official website.
$ wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
2. Once the download is complete, open the archive file on your computer and extract the contents.
$ tar xzf Python-3.10.0.tgz
3. Using the cd command, navigate to the extracted directory and prepare the Python source code for compilation on your system.
$ cd Python-3.10.0 $ ./configure --enable-optimizations
4. Finally, to complete the Python installation on the Debian system, use the following command. The altinstall option prevents the compiler from overriding the Python versions that are installed by default.
$ make altinstall
Wait for Python to finish installing on your computer.
Check Python Version
This completes the installation of Python 3.10 on an Ubuntu or Debian machine. To use this version, type python3.10 on the command prompt. To check the Python version, for example, type:
$ python3.10 -V Python 3.10.0
This will also install pip for Python 3.10.
$ pip3.10 -V pip 21.2.3 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)
That's it; Python 3.10 has been successfully installed on Ubuntu, Debian, and Linux systems.
Conclusion
You learnt how to install Python 3.10 from source code on Ubuntu, Debian, and LinuxMint computers in this tutorial.
COMMENTS