Much to my surprise, I found that a fresh install of Ubuntu 19.10 was set to use python 2.7 as the default python instance.

I have covered changing the default version of python in Debian, however for those looking to Google for a quick fix on Ubuntu 19.10, I hope that this reaches you well.

This was tested on a completely fresh install of Ubuntu 19.10 with no other alterations made prior.

The basic premise is to configure Ubuntu to use python 3.7 at a higher priority to python 2.7 or any other version installed on the system.


Check your python version

Step 1 is to check your current python version:

python -V

or

python --version

Ubuntu 19.10 default output:
Python 2.7.17rc1

Set your Python Default

Now it is time configure the priority for the versions of python that we have installed, 2.7 and 3.5/7. You can list all of the available alternatives installed by running:

ls /usr/bin/python*

Ubuntu 19.10 default output:

v2.7 and 3.7 are available To set your version priorities, with 3.7 being the high priority:

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2

We have just set 3.7 (2) to have a priority great than 2.7 (1). Now when we list the python priorities we see see 3.7 is higher that 2.7:

update-alternatives --config python

This is also a great way to easily switch those priorities around once they have been set.


Check you default version, again…

python -V

Now this command should return the default which you configured above.


Other Useful Python tips:


Exitcode0 Tip Jar If you have found this guide useful or it has solved a burning issue for you, please consider throw a coin in the tip jar to help this site stay active:

https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BTQD4GN8TTWJN&source=url