Python 3 as default Python command

17,768

The simplest is to make an alias in your .bashrc.

To do so open your .bashrc with:

nano ~/.bashrc 

or

nano ~/.bash_aliases

and add in the section # some more aliases a new line containing

alias python='python3'

Open a new terminal and it should work fine.

NOTE: It's not recommended to make a symbolic link in your /usr/bin.

For visual studio code: The settings for python3 has to be set within the program - look at this link how to set the right python path.

Share:
17,768

Related videos on Youtube

user9912524
Author by

user9912524

Updated on September 18, 2022

Comments

  • user9912524
    user9912524 over 1 year

    I am using Visual Studio Code for my Python programming and the problem that I am facing is that on terminal when I type the command python, by default Python 2.7 is loaded. So because of this I am not able to debug my Python 3 commands on my Ubuntu Budgie.

    What should I do in order to uninstall Python 2.7 and make 3.7 as my default Python? I have uninstalled Python 2.7 by using the command sudo apt-get remove python. Even after doing this, I have to type python3 to load Python 3.7 and I get an error when just I type python.

    How do I make my Python 3 default so that when I type python, Python 3.7 starts?

    -Codec Leaper

    • oldfred
      oldfred almost 6 years
      Just use `python3' both at command line and as first line in any python files. Ubuntu uses python3 for many internal thing, a few applications have not been converted yet & still use python2. But you should always be specific in version you want. Never ever remove python. That will break system.
    • wjandrea
      wjandrea almost 6 years
      What version of Ubuntu?
  • user9912524
    user9912524 almost 6 years
    Na man, this was my question from the start 😒
  • abu_bua
    abu_bua almost 6 years
    you are using visual code, you put that later in your question. However, i would use the instruction from the link i gave you. further i suggest to use anaconda. python is to strongly involved in ubuntu, that it is better to set up a totally different python environment.
  • Ryan Loggerythm
    Ryan Loggerythm over 5 years
    nano ~/.bashrc or ~/.bash_aliases