ubuntu18.04 python版本切换

update-alternatives是ubuntu系统中专门维护系统命令链接符的工具,通过它可以很方便的设置系统默认使用哪个命令、哪个软件版本,比如,我们在系统中同时安装了python2.7和python3.6两个版本,而我们又希望系统默认使用的是python3.6,那怎么办呢?通过update-alternatives就可以很方便的实现了。

1.更新替代列表(管理员权限下)

命令格式:update-alternatives --install <link> <name> <path> <priority>

<link> is the symlink pointing to /etc/alternatives/<name>.
  (e.g. /usr/bin/pager)
<name> is the master name for this link group.
  (e.g. pager)
<path> is the location of one of the alternative target files.
  (e.g. /usr/bin/less)
<priority> is an integer; options with higher numbers have higher priority in
  automatic mode.

 

update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2

 

2、查看替代列表:

update-alternatives --list python

 

3、切换:

update-alternatives --config python

 

posted on 2018-09-30 15:19  JASONlee3  阅读(10122)  评论(0编辑  收藏  举报

导航