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)

FAQs

How do I upgrade Python to a specific version in Ubuntu? ›

To install the latest version of Python on Ubuntu, add the deadsnakes PPA to your repository list, update the list, and name the version you want in an apt command like "sudo apt install python3. 12". You can also get the latest Python version installed on Ubuntu by building it from source.

What version of Python is Ubuntu 18.04 LTS? ›

The Python package included with Ubuntu 18.04 is version 3.6. 8 and version 3.8. 10 in Ubuntu 20.04.

How do I update Python in Ubuntu 20.04 terminal? ›

Method to get the newest Python
  1. apt install -y software-properties-common.
  2. apt-get update -y; apt upgrade -y.
  3. add-apt-repository -y ppa:deadsnakes/ppa.
  4. apt-get update && apt-cache search python3.1.
  5. apt-get install python3.11 -y.
  6. ln -s /usr/bin/python3.11 /usr/bin/python.
Oct 3, 2022

How to upgrade Ubuntu 18.04 to 20.04 LTS using command line? ›

The Upgrade
  1. sudo apt update && sudo apt upgrade (This will update all packages on 18.04)
  2. sudo apt install update-manager-core (Installs the Ubuntu update tool)
  3. sudo do-release-upgrade -c (Verifies the version of Ubuntu to upgrade to. ...
  4. sudo do-release-upgrade (Starts to upgrade of the OS)
Apr 14, 2023

How do I upgrade from 18.04 to 20.04 LTS? ›

How to Upgrade Ubuntu 18.04 to 20.04
  1. Apply available updates and reboot. ...
  2. Check MySQL 8.0 configuration compatibility. ...
  3. Make sure all apps are using PHP 7.2 or greater. ...
  4. Uninstall PHP packages. ...
  5. Reboot your server. ...
  6. Update the package manager configuration. ...
  7. Reinstall PHP packages. ...
  8. Update the PHP version used for the "php" command.
Nov 20, 2023

How to update Python to 3.10 in Ubuntu? ›

  1. Prerequisite. sudo apt update sudo apt install software-properties-common -y.
  2. Add custom APT repository. sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update. ...
  3. Install Python 3.10. ...
  4. Install PIP for Python 3.10. ...
  5. Test with system ENV. ...
  6. Test with Virtual ENV. ...
  7. References.

How to upgrade Python using pip in Ubuntu? ›

Upgrade a Python package

Use the command ' pip3 install --upgrade --user <package-name> '. Depending on how the package was installed, you may need to replace the pip3 command with the version of Pip that was used to originally install the package.

Should I upgrade Ubuntu 18.04 to 20.04 LTS? ›

Upgrading to a newer version is strongly recommended! Ubuntu 18.04 will only receive updates and new packages until 2023. We recommend a backup of your data and a new installation, e.g. via our automatic reinstallation service WebFAI.

How to install Python 3.10 on Ubuntu? ›

Follow the steps below:
  1. Step 1: Update the Package Repository. Update the package repository to ensure you get the latest available program version. ...
  2. Step 2: Install Python. After the package repository information is updated, run the command below to install Python: sudo apt install python3. ...
  3. Step 3: Verify Installation.
Dec 14, 2023

What version of Python is Ubuntu 20.04 4 LTS? ›

Other base system changes since 18.04 LTS

In 20.04 LTS, the python included in the base system is Python 3.8.

How to update Python with pip in terminal? ›

Run the command python -m pip install --upgrade pip to update Pip. If this command doesn't work on Windows, use py -m pip install --upgrade pip instead.

How do I update Ubuntu using terminal command line? ›

How to update Ubuntu from the terminal
  1. Enter the following terminal command: sudo apt update && sudo apt upgrade -y.
  2. Press Enter.
  3. Press your password.
Dec 17, 2023

How do I upgrade Ubuntu 18.04 LTS to 22.04 LTS? ›

There is no direct upgrade path from 18.04 LTS to Ubuntu 22.04 LTS, so you can either move to Ubuntu 20.04 LTS and then to Ubuntu 22.04 LTS, or directly install Ubuntu 22.04 LTS.

How do I upgrade to the next LTS version of Ubuntu? ›

There are two ways to upgrade to the latest Ubuntu version: You can use the do-release-upgrade tool, which works for both CLI and GUI instances, or the GUI update tool. During the upgrade, the upgrade tool will probe for the latest LTS release and walk you through a series of prompts.

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.