Set Python 3 as default on Ubuntu 20.04

Your out-of-the-box Ubuntu system likely already has an installation of Python on it. For versions older than Ubuntu 14.10, the default version of Python is 2.7.x. In this article, I will explain how to install Python 3 and how to make this version your default. 



  • Running Ubuntu OS


First, let us check to see which version of Python is installed on the OS.

python -V
Python 2.7.8

See that the version of Python installed is 2.7.8.

What we will do now is install Python 3 and then set that version to the default version to use. 

sudo apt-get update
sudo apt-get install python3.7

Now that Python 3 is installed let’s change the default version. 

For the sake of this article I will be using vi as my text editor, but feel free to use whichever editor you prefer

Open bashrc

sudo vi ~/.bashrc

Find the following line and modify it to reflect the version of Python that needs to be the default. 

alias python='/usr/bin/python3.7'

Next, source or re-load bashrc. 

. ~/.bashrc

Check to see which version of Python is the default.

python -V
Python 3.7.4

Great! You now have Python 3 set as the default. 

Leave a Reply

Your email address will not be published. Required fields are marked *