Planning to get the Python 3.10 installed for your work? Here’s how to install Python 3.10 in Ubuntu and related distributions.
Python 3.10 released on Oct 25, 2021 with additional features and updates. This release brings better handling of error messages, new patter matching features, TypeAlias, user-defined type guards and more. You can read the release highlights here.
As of writing this guide, Python 3.10 is adopted by Fedora 35. However, Ubuntu 21.10 Impish Indri still features Python 3.9.x. The planned Ubuntu 22.04 LTS, would have the Python 3.10 by default.
That said, if you need Python 3.10, right now in Ubuntu 21.10, Ubuntu 21.04 or prior-LTS releases which are still supported, you can use the below reliable PPA to install the latest Python 3.10 in Ubuntu. Here’s how.
How to Install Python 3.10 in Ubuntu
This PPA can be used for Ubuntu 21.10, Ubuntu 21.04, Ubuntu 20.04 LTS, Ubuntu 18.04 LTS, Linux Mint 20.x, Elementary OS 6 and other related Ubuntu-based distributions.
- Open a terminal prompt and add the following PPA.
sudo add-apt-repository ppa:deadsnakes/ppa
- Refresh the cache using the below command.
sudo apt update
- And install Python 3.10 using below command.
sudo apt install python3.10
Set Python Versions
Setting up the Python 3.10 as default require some additional steps. Follow along.
Warning: There are many applications in your Ubuntu system which depends on stock version of Python 3.9. Hence, be very sure that your work applications (e.g. GIMP, GNOME Terminal etc.) are compatible with Python 3.10. So, be cautious.
Quick Tip: If you want to check which of your installed system packages depends on a specific version, use the following rdepend switch of apt-cache command. In the below example, I am checking which of the installed packages depends on Python 3.8.
apt-cache rdepends python3.8
[~]$ apt-cache rdepends python3.8
Use Python 3.10 as default Python3
- First, check the current default version using the below command from the terminal.
- Use update-alternatives to create symbolic links to python3
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
- And choose which one to use as Python3 via command:
sudo update-alternatives --config python3
That’s all for the steps. Now you can start using the latest Python in your current Ubuntu version for your work/study. At any given time, you switch over to the stock version using the above commands and by changing the version numbers.