How to upgrade to Python 3.10 on Ubuntu 18.04 and 20.04 LTS - ITSupportWale (2024)

I was able to solve this issue by running the following steps:

Step 1: Current state of the Python version:

$ python3 -V
Python 3.8.10
$ ls /usr/bin | grep python
python3
python3-config
python3.8
python3.8-config
x86_64-linux-gnu-python3-config
x86_64-linux-gnu-python3.8-config
$
Step 2: Current state of Python alternatives:

$ sudo update-alternatives –config python3
There is 1 choice for the alternative python3 (providing /usr/bin/python3).

Selection Path Priority Status
————————————————————
0 /usr/bin/python3.8 1 auto mode
* 1 /usr/bin/python3.8 1 manual mode

Press to keep the current choice[*], or type selection number:
$
Step 3: Removing existing python3.10 that was attempted before:

$ sudo apt remove python3.10
[sudo] password for vkdevu:
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package python3.10
E: Couldn’t find any package by glob ‘python3.10’
$

$ sudo apt list | grep python3.10

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libqgispython3.10.4/focal,now 3.10.4+dfsg-1ubuntu2 amd64 [installed]
$

$ sudo apt remove libqgispython3.10.4
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
gdal-data libaec0 libarmadillo9 libarpack2 libblas3 libcfitsio8 libcharls2 libdap25 libdapclient6v5 libdouble-conversion3
libepsilon1 libfreexl1 libfwupdplugin1 libfyba0 libgdal26 libgeos-3.8.0 libgeos-c1v5 libgeotiff5 libgfortran5 libgif7
libhdf4-0-alt libhdf5-103 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libminizip1 libnetcdf15 libodbc1 libogdi4.1
libpcre2-16-0 libpoppler97 libproj15 libqca-qt5-2 libqca-qt5-2-plugins libqgis-core3.10.4 libqhull7 libqt5concurrent5
libqt5core5a libqt5dbus5 libqt5gui5 libqt5keychain1 libqt5network5 libqt5positioning5 libqt5printsupport5 libqt5qml5
libqt5quick5 libqt5sensors5 libqt5serialport5 libqt5sql5 libqt5sql5-sqlite libqt5svg5 libqt5webchannel5 libqt5webkit5
libqt5widgets5 libqt5xml5 libspatialindex6 libspatialite7 libsuperlu5 libsz2 liburiparser1 libxcb-xinerama0 libxcb-xinput0
libxerces-c3.2 libzip5 ocl-icd-libopencl1 odbcinst odbcinst1debian2 poppler-data proj-bin proj-data qt5-gtk-platformtheme
qttranslations5-l10n
Use ‘sudo apt autoremove’ to remove them.
The following packages will be REMOVED:
libqgispython3.10.4
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 2379 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database … 130630 files and directories currently installed.)
Removing libqgispython3.10.4 (3.10.4+dfsg-1ubuntu2) …
Processing triggers for libc-bin (2.31-0ubuntu9.9) …
$
Step 4: Ensure that your system is updated and the required packages installed:

$ sudo apt update && sudo apt upgrade -y
Ign:1 https://pkg.jenkins.io/debian binary/ InRelease
Hit:2 https://pkg.jenkins.io/debian binary/ Release
Get:3 http://mirrors.digitalocean.com/ubuntu focal InRelease [265 kB]
Get:5 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease [114 kB]
Get:6 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease [108 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:8 http://mirrors.digitalocean.com/ubuntu focal-updates/main amd64 Packages [1789 kB]
Get:9 http://mirrors.digitalocean.com/ubuntu focal-updates/universe amd64 Packages [921 kB]
Fetched 3310 kB in 2s (1657 kB/s)
Reading package lists… Done
Building dependency tree
Reading state information… Done
All packages are up to date.
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
The following packages were automatically installed and are no longer required:
gdal-data libaec0 libarmadillo9 libarpack2 libblas3 libcfitsio8 libcharls2 libdap25 libdapclient6v5 libdouble-conversion3
libepsilon1 libfreexl1 libfwupdplugin1 libfyba0 libgdal26 libgeos-3.8.0 libgeos-c1v5 libgeotiff5 libgfortran5 libgif7
libhdf4-0-alt libhdf5-103 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libminizip1 libnetcdf15 libodbc1 libogdi4.1
libpcre2-16-0 libpoppler97 libproj15 libqca-qt5-2 libqca-qt5-2-plugins libqgis-core3.10.4 libqhull7 libqt5concurrent5
libqt5core5a libqt5dbus5 libqt5gui5 libqt5keychain1 libqt5network5 libqt5positioning5 libqt5printsupport5 libqt5qml5
libqt5quick5 libqt5sensors5 libqt5serialport5 libqt5sql5 libqt5sql5-sqlite libqt5svg5 libqt5webchannel5 libqt5webkit5
libqt5widgets5 libqt5xml5 libspatialindex6 libspatialite7 libsuperlu5 libsz2 liburiparser1 libxcb-xinerama0 libxcb-xinput0
libxerces-c3.2 libzip5 ocl-icd-libopencl1 odbcinst odbcinst1debian2 poppler-data proj-bin proj-data qt5-gtk-platformtheme
qttranslations5-l10n
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$
Step 5: Install Python 3.10 on Ubuntu 20.04|18.04 using Apt Repo:

$ sudo apt install software-properties-common -y
Reading package lists… Done
Building dependency tree
Reading state information… Done
software-properties-common is already the newest version (0.99.9.8).
software-properties-common set to manually installed.
The following packages were automatically installed and are no longer required:
gdal-data libaec0 libarmadillo9 libarpack2 libblas3 libcfitsio8 libcharls2 libdap25 libdapclient6v5 libdouble-conversion3
libepsilon1 libfreexl1 libfwupdplugin1 libfyba0 libgdal26 libgeos-3.8.0 libgeos-c1v5 libgeotiff5 libgfortran5 libgif7
libhdf4-0-alt libhdf5-103 libkmlbase1 libkmldom1 libkmlengine1 liblapack3 libminizip1 libnetcdf15 libodbc1 libogdi4.1
libpcre2-16-0 libpoppler97 libproj15 libqca-qt5-2 libqca-qt5-2-plugins libqgis-core3.10.4 libqhull7 libqt5concurrent5
libqt5core5a libqt5dbus5 libqt5gui5 libqt5keychain1 libqt5network5 libqt5positioning5 libqt5printsupport5 libqt5qml5
libqt5quick5 libqt5sensors5 libqt5serialport5 libqt5sql5 libqt5sql5-sqlite libqt5svg5 libqt5webchannel5 libqt5webkit5
libqt5widgets5 libqt5xml5 libspatialindex6 libspatialite7 libsuperlu5 libsz2 liburiparser1 libxcb-xinerama0 libxcb-xinput0
libxerces-c3.2 libzip5 ocl-icd-libopencl1 odbcinst odbcinst1debian2 poppler-data proj-bin proj-data qt5-gtk-platformtheme
qttranslations5-l10n
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$
Step 6: Then proceed and add the deadsnakes PPA to the APT package manager sources list:

$ sudo add-apt-repository ppa:deadsnakes/ppa
This PPA contains more recent Python versions packaged for Ubuntu.

Disclaimer: there’s no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.

Update Note
===========
Please use this repository instead of ppa:fkrull/deadsnakes.

Reporting Issues
================

Issues can be reported in the master issue tracker at:
https://github.com/deadsnakes/issues/issues

Supported Ubuntu and Python Versions
====================================

– Ubuntu 18.04 (bionic) Python2.3 – Python 2.6, Python 3.1 – Python 3.5, Python3.7 – Python3.11
– Ubuntu 20.04 (focal) Python3.5 – Python3.7, Python3.9 – Python3.11
– Ubuntu 22.04 (jammy) Python3.7 – Python3.9, Python3.11
– Note: Python2.7 (all), Python 3.6 (bionic), Python 3.8 (focal), Python 3.10 (jammy) are not provided by deadsnakes as upstream ubuntu provides those packages.

Why some packages aren’t built:
– Note: for focal, older python versions require libssl<1.1 so they are not currently built
– Note: for jammy, older python versions requre libssl x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 16 Mar 13 2020 python3-config -> python3.8-config
lrwxrwxrwx 1 root root 31 Mar 13 2020 py3versions -> ../share/python3/py3versions.py
-rwxr-xr-x 1 root root 3241 Mar 15 12:22 x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root 33 Mar 15 12:22 python3.8-config -> x86_64-linux-gnu-python3.8-config
-rwxr-xr-x 1 root root 5490448 Mar 15 12:22 python3.8
lrwxrwxrwx 1 root root 23 Mar 15 12:22 pdb3.8 -> ../lib/python3.8/pdb.py
-rwxr-xr-x 1 root root 5789976 Apr 8 17:35 python3.10
lrwxrwxrwx 1 root root 24 Apr 8 17:35 pdb3.10 -> ../lib/python3.10/pdb.py
lrwxrwxrwx 1 root root 25 May 10 04:37 python3 -> /etc/alternatives/python3
$

$ sudo update-alternatives –config python3
There is 1 choice for the alternative python3 (providing /usr/bin/python3).

Selection Path Priority Status
————————————————————
0 /usr/bin/python3.8 1 auto mode
* 1 /usr/bin/python3.8 1 manual mode

Press to keep the current choice[*], or type selection number:
$

Reply

How to upgrade to Python 3.10 on Ubuntu 18.04 and 20.04 LTS - ITSupportWale (2024)
Top Articles
Latest Posts
Article information

Author: Jonah Leffler

Last Updated:

Views: 5438

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Jonah Leffler

Birthday: 1997-10-27

Address: 8987 Kieth Ports, Luettgenland, CT 54657-9808

Phone: +2611128251586

Job: Mining Supervisor

Hobby: Worldbuilding, Electronics, Amateur radio, Skiing, Cycling, Jogging, Taxidermy

Introduction: My name is Jonah Leffler, I am a determined, faithful, outstanding, inexpensive, cheerful, determined, smiling person who loves writing and wants to share my knowledge and understanding with you.