0

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

  • 1
    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. – oldfred Jul 2 '18 at 18:02
  • What version of Ubuntu? – wjandrea Jul 2 '18 at 18:32
1

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.

  • Na man, this was my question from the start 😒 – user9912524 Jul 4 '18 at 6:33
  • 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. – abu_bua Jul 4 '18 at 9:35
  • nano ~/.bashrc or ~/.bash_aliases – Ryan Loggerythm Jan 16 '19 at 4:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.