Set python3 as default interpreter in Linux
Set python3 as default interpreter in Linux

The ‘python’ program command executes Python2. Python3 should be executed using the python3 command, but python3 can be executed by using the command ‘python’. You can learn “How can Python 3 be executed using the python command?”

Currently, I am using Kali Linux to set Python3 to be executed using the python command.

You will be able to:

  1. Set ‘python’ program command execute Python3
  2. Set cls to clear screen in Linux (Kali Linux, Ubuntu, Fedora, Debian)
  3. Set pip3 as default pip installer (‘pip’ program command execute pip3)

Applicable Operating Systems: Kali Linux, Ubuntu, Debian, Fedora, etc.

Set python3 as default interpreter in Linux

Let set Python 3 be executed using the python command in Linux. I also have pasted a video for you…

Python 3 be executed using the python command | How to Set python3 as default interpreter in Linux

Note: Install gedit by typing (sudo apt install gedit) in terminal

sudo apt install gedit 

Steps and Codes to Set python3 as default interpreter in Linux

  1. Type “sudo gedit ~/.bashrc” in terminal
sudo gedit ~/.bashrc
  1. A new window will pop up
Interface of gedit in Kali Linux terminal
Interface of gedit in Kali Linux terminal
  1. Add the following codes at the top of the text-editor(window)
alias python=python3
alias cls=clear
alias pip=pip3 

Have a look:

#~/.bashrc: executed by bash(1) for non-login shells.
see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
#for examples
#If not running interactively, don't do anything

alias python=python3
alias cls=clear
alias pip=pip3

case $- in
i) ;;
*) return;;
esac
#don't put duplicate lines or lines starting with space in the history.
#See bash(1) for more opti...
  1. Click on “SAVE”
  2. Done… Close all and open a new terminal (CTRT+ALT+T)
  3. Type ‘python’ to test.
python

Do you want to make money coding Python? If yes, click me to make money coding Python

The result after setting python3 as default interpreter in Linux

codie@kali:~$ python
Python 3.8.3 (default, May 14 2020, 11:03:12)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Result after setting python3 as default interpreter in Linux in Terminal
Result after setting python3 as default interpreter in Linux in Terminal
  1. Successfully set python3 as default interpreter in Linux…
    And also cls can clear the screen of Linux terminal. And you can use pip to install python packages as pip3.

Hope it helped you…

Keep learning Python, because it’s #Beneficial_Python.

Thanks!!!

Happy Pythoning…

Last modified: August 21, 2020

Author

4.5 2 votes
Article Rating
Subscribe
Notify of
guest
8 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Rabin Bhandari

This article really helped me. I was search to set ‘python‘ command to run python permanently. Thanks man…

Bishwas Bhandari

You’re most welcomed brother. I hope you successfully set python3 as your default interpreter to run python3 with ‘python’ command.

Python Programmer

Thanks bro. I also worked for me. We can also use mousepad to edit the code. Here’s how:

sudo mousepad ~/.bashrc
Bishwas Bhandari

Yes bro, you can use whatever editor you want…

Prabin Maharjan

Thanks brother it helped me to set python3 as default interpreter in my Debian OS.Finally I can execute python3 with “Python” command in my Linux destro. Really helped me.

Bishwas Bhandari

Welcome bro and congrats. .Finally you can execute python3 with “Python” command in my Linux destro. Really helped you.

John Derek

Really helped. Amazingly I can get python command to run python3.

Bishwas Bhandari

Of course, It’ll work…