Python is one of the most popular high-level languages, focusing on high-level and object-oriented applications from simple scrips to complex machine learning algorithms. Python 3.10 is the latest release and is not classed as stable compared the Python 3.9, but the final candidate is expected to be completed on the 4th of October 2021.
Some of the features Python can do:
- Python can be used on a server to create web applications.
- Python can be used alongside software to create workflows.
- Python can connect to database systems. It can also read and modify files.
- Python can be used to handle big data and perform complex mathematics.
- Python can be used for rapid prototyping or production-ready software development.
For users and especially developers wanting to try out Python’s latest release, at the end of this guide, you will know how to install Python 3.10 on Ubuntu 20.04 LTS. The same principle will work for the newer version Ubuntu 21.04 (Hirsute Hippo).
- Recommended OS: Ubuntu 20.04 – optional (Ubuntu 21.04 and Linux Mint 20)
- User account: A user account with sudo or root access.
- Required packages: wget
Check and update your Ubuntu 20.04 operating system.
sudo apt update && sudo apt upgrade -y
Make sure the wget package is installed if using the alternative installation method from the source.
sudo apt install wget
Install Python 3.10 using Apt
To install the latest versions of Python 3.10 is relatively a straightforward process on Ubuntu, thanks to custom PPAs. To install and receive continued updates for new features, bug fixes and important security updates, you will add the (deadsnakes/ppa).
First, install the prerequisite for adding custom PPAs:
sudo apt install software-properties-common -y
Second, add the (deadsnakes/ppa) to your APT package manager sources list:
sudo add-apt-repository ppa:deadsnakes/ppa -y
Once the repository has been installed, you can now install Python 3.10 by executing the following code:
sudo apt install python3.10
You will see the following packages installed in your installation:
To verify the installation and Python 3.10 build version, execute the following:
Example output at the time of this tutorial creation:
Install Python 3.10 on Ubuntu from Source
The alternative option for those that feel up to more of a challenge or require certain advanced builds from the git repository of the source can opt to install directly from the source. The main issue with this method is that you cannot easily update like you would with the APT package manager and will need to recompile for any changes.
First, you will need to install the dependencies necessary to build Python 3.10:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
The second part is visiting the downloads page on Python’s website and getting the latest version using (wget):
The file archive is small, so it won’t take a long time to download. Once done, extract the archive:
tar -xf Python-3.10.0b4.tgz
You will need to switch to the source directory and run the configuration script, which does a basic run-through checklist to make sure all dependencies are present for the installation to work.
&& ./configure --enable-optimizations
Note, the (–enabled-optimizations) is recommended as it optimizes the Python binary by running multiple tests but takes extra time to compete. Overall the process should take a few minutes, so it’s recommended not to skip.
Example end output:
The next option is to use the (make) command to start the build process.
make -j 2
Note, the (-j) corresponds to the number of cores in your system to speed up the build time. If you have a powerful server, you can set this as high as you like. If you don’t, then it will be the default option of 1. To find out how many cores you have on your system, execute the following code:
As you can see, we have 2 cores, so in the (make) command, we used (-j 2).
In the last step, once you have finished with the build process, you will install Python 3.10 source by executing the following:
sudo make altinstall
Note, the guide has used (altinstall) instead of the default (install) because it will overwrite the default system python3 binary.
Check the version of the installation to make sure it has been installed successfully and its current build number:
Comments and Conclusion
The guide has shown you how to install the latest version of Python 3.10 on your Ubuntu 20.04 LTS operating system through using the custom PPA (recommended) or installing from source (developers).