By default most of the IDE where we write code for python uses the Python3 interpreter. This is because the support for Python version 2.* has already ended. Although many code base of our operating system and different software application still has code from version 2.
Python 2.7 support ended on January 1, 2020. Now a days every code in python is written in python3. With that in mind, we are writing this quick and easy tweak which helps to make python3 as your default version of python.
This can be done from your linux terminal with the following steps:Check python version on terminal – python --version
Get root user privileges. On terminal type – sudo su
Write down the root user password
Execute this command to switch to python 3.6 –update-alternatives --install /usr/bin/python python /usr/bin/python3 1
Check python version – python --version
- First, make sure that your python version is not python3:
python --version
- Now with your root privileges open superuser prompt:
sudo su
- Now update the alternative to version 3 of python
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
- Exit the root prompt
- Finally, check your python version
With this one-liner Linux terminal command, you will now be running your python code and application in Python3 from the terminal.