Update Python3 to 3.7 from the CLI without breaking APT

A crash course to using `update-alternatives`

First, check the current python3 version reference with python3:

You can have python37 output python 3.7.x (where x is the latest version digit) using update-alternatives. First, install Python 3.7.

To make the change, we’ll be using the tool update-alternatives. For more information about this tool, see the man page man update-alternatives.

Next, update alternatives, which with the --install option which expects a <LINK>, <NAME>, <PATH>, and <PRIORITY>.

Now, tell 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.

Now when you check the version of python37 it should now read python3.7.x .

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 apt!

If you are having a problem with apt breaking after updating python3 willy-nilly (it happens) you can fix it with this one-liner:

Check the versions before calling it fixed:

Hope this article help somebody! Thanks for reading! ❤

I write about DFIR, GRC, and defensive security topics.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store