Python 3 as default Python command
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.
Related videos on Youtube
user9912524
Updated on September 18, 2022Comments
-
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 typepython3
to load Python 3.7 and I get an error when just I typepython
.How do I make my Python 3 default so that when I type
python
, Python 3.7 starts?-Codec Leaper
-
oldfred almost 6 yearsJust 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 almost 6 yearsWhat version of Ubuntu?
-
-
user9912524 almost 6 yearsNa man, this was my question from the start 😒
-
abu_bua almost 6 yearsyou 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 over 5 years
nano ~/.bashrc
or~/.bash_aliases