您的位置:首页 > 编程语言 > Python开发

ubuntu18.04 python版本切换

2020-06-02 06:18 330 查看

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: