Make Python3 as Default in Ubuntu Machine
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.
- Open Terminal
cd
nano ~/.bashrc
alias python=python3
(Add this line on top of .bashrc file) oralias python=/usr/local/bin/python3.9
- Press
ctr+o
(To save the file) - Press
Enter
- Press
ctr+x
(To exit the file) 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.