在多个Python版本共存时,经常需要切换默认python的版本。查了下对于ubuntu和debian系统可以使用下面的方法:
首先设置python2为默认:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
返回:
update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in auto mode
同样方法,再设置python3为默认:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
返回:
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
设置好之后,可以使用下面的指令自由切换python的默认版本
sudo update-alternatives --config python
返回:
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:
如上图所示,输入对应的数字就可以切换成对应的版本了。
最新评论
十塊年費是直接從這張卡裡的外幣按匯率扣?
有人申请成功了吗?我的已经两天了,没有消息,没有收到成功邮件。信用卡扣了款!