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 <enter> 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<3 so they are not currently built
- If you need these, reach out to asottile to set up a private ppa
The packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported.
Packages
========
The packages provided here are loosely based on the debian upstream packages with some modifications to make them more usable as non-default pythons and on ubuntu. As such, the packages follow debian's patterns and often do not include a full python distribution with just `apt install python#.#`. Here is a list of packages that may be useful along with the default install:
- `python#.#-dev`: includes development headers for building C extensions
- `python#.#-venv`: provides the standard library `venv` module
- `python#.#-distutils`: provides the standard library `distutils` module
- `python#.#-lib2to3`: provides the `2to3-#.#` utility as well as the standard library `lib2to3` module
- `python#.#-gdbm`: provides the standard library `dbm.gnu` module
- `python#.#-tk`: provides the standard library `tkinter` module
Third-Party Python Modules
==========================
Python modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won't work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won't.
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:
https://packaging.python.org/installing/
Sources
=======
The package sources are available at:
https://github.com/deadsnakes/
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.
Get:1 http://mirrors.digitalocean.com/ubuntu focal InRelease [265 kB]
Ign:2 https://pkg.jenkins.io/debian binary/ InRelease
Hit:3 https://pkg.jenkins.io/debian binary/ Release
Hit:4 http://mirrors.digitalocean.com/ubuntu focal-updates InRelease
Hit:5 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:6 http://mirrors.digitalocean.com/ubuntu focal-backports InRelease
Get:7 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal InRelease [18.1 kB]
Get:9 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 Packages [22.5 kB]
Get:10 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main Translation-en [5204 B]
Fetched 311 kB in 2s (144 kB/s)
Reading package lists... Done
$
Step 7: Download Python 3.10 with the single command below:
$ sudo apt install python3.10
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 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 0 not upgraded.
Need to get 5171 kB of archives.
After this operation, 20.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.10-minimal amd64 3.10.4-1+focal2 [820 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-minimal amd64 3.10.4-1+focal2 [2073 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.10-stdlib amd64 3.10.4-1+focal2 [1746 kB]
Get:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10 amd64 3.10.4-1+focal2 [532 kB]
Fetched 5171 kB in 5s (1098 kB/s)
Selecting previously unselected package libpython3.10-minimal:amd64.
(Reading database ... 130626 files and directories currently installed.)
Preparing to unpack .../libpython3.10-minimal_3.10.4-1+focal2_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.4-1+focal2) ...
Selecting previously unselected package python3.10-minimal.
Preparing to unpack .../python3.10-minimal_3.10.4-1+focal2_amd64.deb ...
Unpacking python3.10-minimal (3.10.4-1+focal2) ...
Selecting previously unselected package libpython3.10-stdlib:amd64.
Preparing to unpack .../libpython3.10-stdlib_3.10.4-1+focal2_amd64.deb ...
Unpacking libpython3.10-stdlib:amd64 (3.10.4-1+focal2) ...
Selecting previously unselected package python3.10.
Preparing to unpack .../python3.10_3.10.4-1+focal2_amd64.deb ...
Unpacking python3.10 (3.10.4-1+focal2) ...
Setting up libpython3.10-minimal:amd64 (3.10.4-1+focal2) ...
Setting up python3.10-minimal (3.10.4-1+focal2) ...
Setting up libpython3.10-stdlib:amd64 (3.10.4-1+focal2) ...
Setting up python3.10 (3.10.4-1+focal2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
$
Step 8: Verify the installation by checking the installed version:
$ python3.10 --version
Python 3.10.4
$
Step 9: Add Python 3.10.4 to alternatives config:
$ ls -lrt /usr/bin/ | grep python
lrwxrwxrwx 1 root root 33 Mar 13 2020 x86_64-linux-gnu-python3-config -> 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 <enter> to keep the current choice[*], or type selection number:
$
$ python3 -V
Python 3.8.10
$ python -V
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
$
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
$
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.10 2 auto mode
1 /usr/bin/python3.10 2 manual mode
* 2 /usr/bin/python3.8 1 manual mode
Press <enter> to keep the current choice[*], or type selection number: 0
update-alternatives: using /usr/bin/python3.10 to provide /usr/bin/python3 (python3) in auto mode
$
$
$ python3 -V
Python 3.10.4
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3.10 2 auto mode
1 /usr/bin/python3.10 2 manual mode
2 /usr/bin/python3.8 1 manual mode
Press <enter> to keep the current choice[*], or type selection number:
$
Thank you all for looking at my post.
Best regards,
~Ram