Operating System:Ubuntu 18.04
1. 设置优先级
这里我们默认让python3.6优先级150,高于python2.7优先级100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
2.python2.7与python3.6的切换
sudo update-alternatives --config python
选中后输入0,选中python3(默认)
显示结果:
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3 150 auto mode
1 /usr/bin/python2 100 manual mode
2 /usr/bin/python3 150 manual mode
Press <enter> to keep the current choice[*], or type selection number:
选中后输入1,选中python2
显示结果:
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3 150 auto mode
* 1 /usr/bin/python2 100 manual mode
2 /usr/bin/python3 150 manual mode
Press <enter> to keep the current choice[*], or type selection number:
网友评论