We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install Python 3.10 on Ubuntu 22.04|20.04|18.04

Learn how to – How To Install Python 3.10 on Ubuntu 22.04|20.04|18.04.

Python is one of the widely used, open-source, high-level object-oriented programming language with a large community. It gains popularity due to its simplicity and easy-to-learn syntax. Python can be used to build all types of applications ranging from small and simple scripts to complex machine learning algorithms.

Python 3.10 is the latest release version of Python but not as stable as compared to Python 3.9 but the final candidate is expected to be completed soon. Python 3.10 comes with the following features:

  1. Ability to type hint lists and dictionaries directly
  2. More flexible decorators
  3. Removal of deprecated compatibility code
  4. A More powerful Python parser
  5. New HTTP status codes
  6. Proper Time Zone support
  7. Security updates e.t.c

Some of the main uses of Python are:

  1. Used alongside software to create workflows.
  2. Used on a server to create web applications.
  3. Rapid prototyping or production-ready software development.
  4. Handle big data and perform complex mathematics.
  5. Connect to database systems, read and modify files.

While the installation of Python 3.10 on Ubuntu may prove to be a challenging task for novices, coding and programming with Python can also present its own set of difficulties, particularly for students. Seeking assistance with Python homework help could be a valuable resource in overcoming these challenges.

This guide demonstrates how to install Python 3.10 on Ubuntu 22.04|20.04|18.04. I will cover two methods to get Python 3.10 on the system.

  • Install Python 3.10 from the deadsnakes PPA
  • Manually build Python 3.10 from the source code

Getting Started

Ensure that your system is updated and the required packages installed.

sudo apt update && sudo apt upgrade -y

Option 1 – Install Python 3.10 on Ubuntu using Apt Repository

Installing Python 3.10 on Ubuntu using APT is quite easy, a big thumbs up to the deadsnakes custom PPA! This makes it easy to install Python on Ubuntu and be able to receive continued updates, bug fixes, and security updates.

Install the required dependency for adding custom PPAs.

sudo apt install software-properties-common -y

Then proceed and add the deadsnakes PPA to the APT package manager sources list as below.

sudo add-apt-repository ppa:deadsnakes/ppa

Press Enter to continue.

To install 3rd-party Python modules, you should use the common Python packaging tools.  For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide:

The package sources are available at:

Nightly Builds

For nightly builds, see ppa:deadsnakes/nightly https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly
 More info: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
Press [ENTER] to continue or ctrl-c to cancel adding it

With the deadsnakes repository added to your Ubuntu system, now download Python 3.10 with the single command below.

sudo apt install python3.10

Dependency Tree:

Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3.10-minimal libpython3.10-stdlib python3.10-minimal
Suggested packages:
  python3.10-venv binfmt-support
The following NEW packages will be installed:
  libpython3.10-minimal libpython3.10-stdlib python3.10 python3.10-minimal
0 upgraded, 4 newly installed, 0 to remove and 192 not upgraded.
Need to get 5,023 kB of archives.
After this operation, 19.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Verify the installation by checking the installed version.

$ python3.10 --version

Option 2 – Install Python 3.10 on Ubuntu from Source.

The other alternative to get Python 3.10 installed on your Ubuntu system is by building it from the source code. With this installation method, you are guaranteed the latest Python Version although you will not be able to receive continued updates, bug fixes, and security updates through the APT package manager.

Install the required dependencies to build Python 3.10 from the source.

sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev

Now proceed and download the latest release version of Python from the Python official release page. Alternatively, copy the download link for Python 3.10 gzipped tarball and use Wget to pull it as below.

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

When this file has been downloaded, proceed and extract it.

tar -xf Python-$VERSION.tgz

Now navigate into the extracted directory and run the configure script to check the required dependencies. The –-enable optimization flag optimizes the binary by running multiple tests.

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


checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.10... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "linux"
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out

configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile

Now initiate the Python 3.10 build process as below.

make -j $(nproc)

Remember the -j argument should match the number of cores on your system for the process to be faster. Check the number of cores on your system using the command nproc. For this instance, I have 2 cores on my system.

Sample Output:

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  pwd                   time               

running build_scripts
copying and adjusting /home/ubuntu/Python-3.10.11/Tools/scripts/pydoc3 -> build/scripts-3.10
copying and adjusting /home/ubuntu/Python-3.10.11/Tools/scripts/idle3 -> build/scripts-3.10
copying and adjusting /home/ubuntu/Python-3.10.11/Tools/scripts/2to3 -> build/scripts-3.10
changing mode of build/scripts-3.10/pydoc3 from 644 to 755
changing mode of build/scripts-3.10/idle3 from 644 to 755
changing mode of build/scripts-3.10/2to3 from 644 to 755
renaming build/scripts-3.10/pydoc3 to build/scripts-3.10/pydoc3.10
renaming build/scripts-3.10/idle3 to build/scripts-3.10/idle3.10
renaming build/scripts-3.10/2to3 to build/scripts-3.10/2to3-3.10
make[1]: Leaving directory '/home/ubuntu/Python-3.10.11'

With the build process complete, now issue the make command below to install Python 3.10 on Ubuntu.

sudo make altinstall

Here altinstall is used instead of install in order to keep the default Python binary path in /usr/bin/python.

Sample Output:

Looking in links: /tmp/tmpwbk6rtev
Processing /tmp/tmpwbk6rtev/setuptools-57.4.0-py3-none-any.whl
Processing /tmp/tmpwbk6rtev/pip-21.2.3-py3-none-any.whl
Installing collected packages: setuptools, pip
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /usr/local/include/python3.10/setuptools
  sysconfig: /home/ubuntu/Python-3.10.11/Include/setuptools
  WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
  distutils: /usr/local/include/python3.10/pip
  sysconfig: /home/ubuntu/Python-3.10.11/Include/pip
Successfully installed pip-21.2.3 setuptools-57.4.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

Verify your installation.

$ python3.10 --version
Python 3.10.11

Install Python Modules|Extensions on Ubuntu 20.04|18.04

Modules and extensions are useful in Python as they add functionality to it. Modules can be installed on Ubuntu 20.04|18.04 using the Python Package manager (PIP). You need to have PIP installed on your system as below

sudo apt install python3-pip

Then use the syntax below to install a Python module of choice.

sudo pip install module-name

In this guide, I will demonstrate how to install a Python module beautifulsoup4.

sudo pip install beautifulsoup4


Collecting beautifulsoup4
  Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 259 kB/s 
Collecting soupsieve>1.2
  Downloading soupsieve-2.2.1-py3-none-any.whl (33 kB)
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.10.0 soupsieve-2.2.1

You can list locally installed Python packages using the command:

$ pip list
Package                Version             
---------------------- --------------------
attrs                  19.3.0              
Automat                0.8.0               
beautifulsoup4         4.10.0              
blinker                1.4                 
certifi                2019.11.28          
chardet                3.0.4               
Click                  7.0                 
cloud-init             20.2                
colorama               0.4.3               
command-not-found      0.3                 
configobj              5.0.6               
constantly             15.1.0              
cryptography           2.8                 
dbus-python            1.2.16              
distro                 1.4.0               
distro-info            0.23ubuntu1         
entrypoints            0.3                 
httplib2               0.14.0              
hyperlink              19.0.0     

That is it! I hope you enjoyed this guide on how to install Python 3.10 on Ubuntu 22.04|20.04|18.04. You are now set to use Python to build web applications, software development, create workflows e.t.c

See more guides on this page:


Your Cart is Empty

Back To Shop