How to fix "update-alternatives: warning: forcing reinstallation of alternative /usr/bin/python3.8 because link group python3 is broken"?

Viewed 6443

Working with Ubuntu 16.04.7 I was trying to make python3.8 my default python version. I followed the instructions given here, but in the end the standard python version did not change. Whenever I run

python -V

the output was always

Python 3.7.9

Here is the output of 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.8   2         auto mode
  1            /usr/bin/python3.7   1         manual mode
  2            /usr/bin/python3.8   2         manual mode

Press <enter> to keep the current choice[*], or type selection number:

When I select '0' I get the error:

update-alternatives: warning: forcing reinstallation of alternative /usr/bin/python3.8 because link group python3 is broken

The only close hit on google is another SO entry with no answers!

So how can I fix this problem?

Also, here is the output of ls -l /usr/bin/python*:

lrwxrwxrwx 1 root root      18 Oct 17  2019 /usr/bin/python -> /usr/bin/python2.7
lrwxrwxrwx 1 root root       9 Nov 24  2017 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3488528 Jul 21 19:57 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Jul 21 19:57 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Nov 24  2017 /usr/bin/python2-config -> python2.7-config
-rwxr-xr-x 1 root root     306 Oct 24  2015 /usr/bin/python2-futurize
-rwxr-xr-x 1 root root     310 Oct 24  2015 /usr/bin/python2-pasteurize
lrwxrwxrwx 1 root root      25 Oct  5 08:59 /usr/bin/python3 -> /etc/alternatives/python3
-rwxr-xr-x 2 root root 4456208 Jul 19 22:14 /usr/bin/python3.5
lrwxrwxrwx 1 root root      33 Jul 19 22:14 /usr/bin/python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4456208 Jul 19 22:14 /usr/bin/python3.5m
lrwxrwxrwx 1 root root      34 Jul 19 22:14 /usr/bin/python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x 2 root root 5074632 Aug 18 09:35 /usr/bin/python3.7
-rwxr-xr-x 2 root root 5074632 Aug 18 09:35 /usr/bin/python3.7m
-rwxr-xr-x 1 root root 5391992 Sep 26 00:51 /usr/bin/python3.8
lrwxrwxrwx 1 root root      16 Mar 23  2016 /usr/bin/python3-config -> python3.5-config
lrwxrwxrwx 1 root root      10 Mar 23  2016 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root      17 Mar 23  2016 /usr/bin/python3m-config -> python3.5m-config
lrwxrwxrwx 1 root root      16 Nov 24  2017 /usr/bin/python-config -> python2.7-config
lrwxrwxrwx 1 root root      58 Mar 25  2016 /usr/bin/pythontex -> ../share/texlive/texmf-dist/scripts/pythontex/pythontex.py
-rwxr-xr-x 1 root root     306 Mar 25  2016 /usr/bin/pythontex3
2 Answers

I had an alias defined for python! That is why conventional logic did not apply here!

I make py3.8 as default by this way

export py=`which python`
sudo rm $py
export py38=`which python3.8`
sudo ln -s $py38 $py
Related