ubuntu18.04 python版本切换

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

命令格式:update-alternatives --install 路径1 名称 路径2 版本

路径1 is the symlink pointing to /etc/alternatives/名称.
(e.g. /usr/bin/pager)
名称 is the master name for this link group. (e.g. pager)
路径2 is the location of one of the alternative target files (e.g. /usr/bin/less)
版本 is an integer; options with higher numbers have higher priority in automatic mode.

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

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

2、查看替代列表:

sudo update-alternatives --list python

在这里插入图片描述
3、切换:

sudo update-alternatives --config python

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值