Make Python3 as Default in Ubuntu Machine

ARAVIND ALLU
Mar 15, 2021

--

Install Python from the official Python-website.

Before making the changes, we need to check the default version of python in the machine by using the following command.

python --version

Python 2.7.17

To make python3 as default python by replacing python2 in Ubuntu, follow the below process.

  1. Open Terminal
  2. cd
  3. nano ~/.bashrc
  4. alias python=python3 (Add this line on top of .bashrc file) or alias python=/usr/local/bin/python3.9
  5. Press ctr+o (To save the file)
  6. Press Enter
  7. Press ctr+x (To exit the file)
  8. source ~/.bashrc OR . ~/.bashrc (To refresh the bashrc file)

python --version

Python 3.9.2

In this way, we can make the default version as Python3 in Ubuntu/Linux machines.

--

--