'Installed python3.9 not showing in linux

I installed python 3.9 following the steps in this link.

  1. sudo apt update
  2. sudo apt install python3.9
  3. python3.9
  4. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.[old-version] 1
  5. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
  6. sudo update-alternatives --config python3

However, it's throwing an error that python3.9 not found on the 3rd point. Also, I noticed the python3.9 on installation using the 2nd point is showing Note, selecting 'postgresql-plpython3-9.5' for regex 'python3.9'.

Complete message is

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'postgresql-plpython3-9.5' for regex 'python3.9'
The following packages were automatically installed and are no longer required:
  linux-aws-headers-4.4.0-1104 linux-aws-headers-4.4.0-1105 linux-aws-headers-4.4.0-1106 linux-aws-headers-4.4.0-1107 linux-aws-headers-4.4.0-1109 linux-aws-headers-4.4.0-1110 linux-aws-headers-4.4.0-1111
  linux-aws-headers-4.4.0-1112 linux-aws-headers-4.4.0-1113 linux-aws-headers-4.4.0-1114
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  postgresql-plpython3-9.5
0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 0 B/40.6 kB of archives.
After this operation, 166 kB of additional disk space will be used.
Selecting previously unselected package postgresql-plpython3-9.5.
(Reading database ... 362651 files and directories currently installed.)
Preparing to unpack .../postgresql-plpython3-9.5_9.5.25-0ubuntu0.16.04.1_amd64.deb ...
Unpacking postgresql-plpython3-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Processing triggers for postgresql-common (173ubuntu0.3) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Setting up postgresql-plpython3-9.5 (9.5.25-0ubuntu0.16.04.1) ...

Why is it setting up postgresql-plpython3-9.5 and how can I prevent it from doing so?



Solution 1:[1]

You may have it already installed

try running $ python3 --version to see what python version your running. If its not installed try running $ sudo apt-get update then run $ sudo apt-get install python3.9 to install python3.9

Hopefully this will help

Solution 2:[2]

You will need to add the deadsnakes repo.

sudo add-apt-repository ppa:deadsnakes/ppa

After that you can follow the steps in your question.

If you still have the same issues after adding the deadsnakes repo, it probably means your running an unsupported version of linux. You might then have to install Python 3.9 from source, you can check this answer on how to do that.

Solution 3:[3]

The deadsnakes ppa is no longer available for Ubuntu Xenial. That's the reason you cannot install python3.9. See this issue. You will have to compile from source or upgrade your server to a supported version of Ubuntu.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mr. Day
Solution 2 nobody
Solution 3 itsafire