Partial Credit:
How to update-alternatives to Python 3 without breaking apt?
Here is the road I went down to solve this problem :-)
sudo update-alternatives --query python
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python3
Value: /usr/bin/python3
Alternative: /usr/bin/Python-3.7.0/python
Priority: 1
Alternative: /usr/bin/python3
Priority: 10
Alternative: /usr/bin/python3.8
Priority: 2
By default, the HIGHEST number (10) as the default python distro for the OS (but this can be overridden)
Then Ran:
# to get rid of one than I last installed that started my problems
command: sudo update-alternatives --remove python /usr/bin/Python-3.7.0/python
reply : update-alternatives: warning: forcing reinstallation of alternative /usr/bin/python3 because link group python is broken
Then ran this again to get a new view of what is contained in update-alternatives
sudo update-alternatives --query python
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python3
Value: /usr/bin/python3
Alternative: /usr/bin/python3
Priority: 10
Alternative: /usr/bin/python3.8
Priority: 2
Wonderful - problem python removed. But I noticed 2.7 was not in the mix and I think that's what used to be the default in my 20.04 xfce distro so ran
You have to supply a priority number so I gave it new 'high' of 12 which should make the OS priority
Command: sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 12
Replied: update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
The above seems to indicate it made 2.7 the default. Let's have a look
sudo update-alternatives --query python
Indeed it did !
sudo update-alternatives --query python
Name: python
Link: /usr/bin/python
Status: auto
Best: /usr/bin/python2.7
Value: /usr/bin/python2.7
Alternative: /usr/bin/python2.7
Priority: 12
Alternative: /usr/bin/python3
Priority: 10
Alternative: /usr/bin/python3.8
Priority: 2
Ran: python -V
Replied: Python 2.7.18
Command: sudo update-alternatives --config python
Reply:
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python2.7 12 auto mode
1 /usr/bin/python2.7 12 manual mode
2 /usr/bin/python3 10 manual mode
3 /usr/bin/python3.8 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
This is great. Allows me to switch between them and test the results
At this point I have a better understanding of Python configs but apt-get update still hosed...
So so more reading led me here.
cd /etc/alternatives
ls -l python*
lrwxrwxrwx 1 root root 18 Jan 24 13:54 python -> /usr/bin/python2.7
lrwxrwxrwx 1 root root 18 Jan 24 13:59 python3 -> /usr/local/bin/python3.7
That second one looked wonky. Was pointing to /usr/local and not /usr/bin so wasn't global. So I linked it to the 3.7 in /usr/bin with the following
sudo rm /etc/alternatives/python3
sudo ln -s /usr/bin/python3.7 /etc/alternatives/python3
Then had another go at it
sudo apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:2 https://pkgs.tailscale.com/stable/ubuntu focal InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:7 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Fetched 228 kB in 2s (112 kB/s)
Reading package lists... Done
RESOLVED !!!!!
This was such a critical problem and resulting solution that I created this post so others could find this needle in the haystack