美文网首页
ubuntu 切换默认python版本

ubuntu 切换默认python版本

作者: ccccxxxxcccc | 来源:发表于2019-10-14 18:45 被阅读0次

可以通过以下命令来查看系统中的python文件

ls /usr/bin/python*

查看python可替换版本信息

update-alternatives --list python

如果出现 update-alternatives:error:no alternatives for python的错误,则表示Python 的替换版本尚未被update-alternatives 命令识别。想解决这个问题,我们需要更新一下替换版本,将Python2.7和python3.5放入其中。执行以下命令:

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

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 150

接下来再次查看python可替换信息

update-alternatives --config python

可以看到当前默认版本是3.5,这时输入 1  就可以切换到2.7版本;

如果当前默认是2.7,那么则输入 2  切换为3.5版本。

然后输入python --version 查看当前默认版本

相关文章

网友评论

      本文标题:ubuntu 切换默认python版本

      本文链接:https://www.haomeiwen.com/subject/iuqdmctx.html