Update Python3 to 3.7 from the CLI without breaking APT
First, check the current python3 version reference with
$ python3 -V
You can have python37 output
python 3.7.x (where x is the latest version digit) using update-alternatives. First, install Python 3.7.
$ sudo apt-get install python3.7
To make the change, we’ll be using the tool
update-alternatives. For more information about this tool, see the man page
Next, update alternatives, which with the
--install option which expects a <LINK>, <NAME>, <PATH>, and <PRIORITY>.
$ sudo update-alternatives --install /usr/bin/python37 python37 /usr/bin/python3.7 1
update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python37 (python37) in auto mode
alternatives to use python3.7 when
python37 is referenced. If you have multiple python 3.7 versions, you would select which version is to be reference when
python37 is called.
$ sudo update-alternatives --config python37
There is only one alternative in link group python37 (providing /usr/bin/python37): /usr/bin/python3.7
Nothing to configure.
Now when you check the version of
python37 it should now read
$ python37 -V
Updating python3 from 3.6 to 3.7 broke apt for me and was a bit of a bummer. Now you can use python 3.7 without breaking
If you are having a problem with
apt breaking after updating
python3 willy-nilly (it happens) you can fix it with this one-liner:
$ sudo update-alternatives --set python3 /usr/bin/python3.6
update-alternatives: using /usr/bin/python3.6 to provide /usr/bin/python3 (python3) in manual mode
Check the versions before calling it fixed:
$ python3 -V
Python 3.6.9$ python37 -V
Hope this article help somebody! Thanks for reading! ❤