Using the alternate mechanism, you can freely switch to the Python default version by simply entering a few simple instructions at the terminal:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
These two instructions add 2 alternate entries--install followed by the Python installation path
The last 100 and 150 parameters represent a non-specified run version priority
That is, after entering these 2 instructions, Python3 becomes the default execution version of the system.
So what do I do if I want to switch back to Python2?
Very simply, alternate allows us to specify the running version manually. In Terminal input:
sudo update-alternatives --config python
The terminal appears with the following prompt:
There are 2 candidates that can be used to replace Python (providing/usr/bin/python).
Select Path Priority state
------------------------------------------------------------
* 0/usr/bin/python3 150 Auto mode
1/usr/bin/python2 100 Manual Mode
2/usr/bin/python3 150 Manual Mode
To maintain the current value [*], press < Enter, or type the number you selected:
Then if you want to switch back to Python2, here I enter 1, and then press ENTER, you can switch back to the original version
Of course, this command also allows us to switch versions freely.
Linux switches Python2 and python3 to the default execution of versions (can also be used for the default execution of editors such as Sublime)