How to set Python 3 as default in linux?

3

When I type the command python , Ubuntu runs Python 2.7. But in the new versions of Ubuntu, Python 3 is also usually installed.

When I run python -V , "Python 2.7.12" appears, but I would like to use the python command to run the 3.5 version.

I could create a symbolic link or something like that, but as I do not know if this is the right thing to do, I ask:

Is there a specific way to change the default version of the python command, without harming or harming Ubuntu?

    
asked by anonymous 29.06.2018 / 14:31

2 answers

1

I solved the problem by creating an alias through ~/.bashrc .

Code

>> nano  ~/.bashrc

Put the following code at the end

alias python=python3

One could say that the command upate-alternatives could solve this, but of according to this answer is not correct use in the case of Python.

    
29.06.2018 / 18:50
2

Dude, I would not change the default python system for the simple fact that things the system uses and depend on python 2 would crash if you changed.

A good practice is to use virtual environments, in this guide you find a legal material about it.

link

As mentioned in the comments, here is also more information about using virtual environments

What is the purpose of virtualenv and why not install globally?

    
29.06.2018 / 14:44