无法在ubuntu中将默认python版本设置为python3 [英] Unable to set default python version to python3 in ubuntu

查看:239
本文介绍了无法在ubuntu中将默认python版本设置为python3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Ubuntu 16.04中的默认python版本设置为python3.默认情况下,它是python2(2.7).我遵循以下步骤:

I was trying to set default python version to python3 in Ubuntu 16.04. By default it is python2 (2.7). I followed below steps :

update-alternatives --remove python /usr/bin/python2
update-alternatives --install /usr/bin/python python /usr/bin/python3

但是第二条语句

rejeesh@rejeesh-Vostro-1015:~$ update-alternatives --install /usr/bin/python python /usr/bin/python3
update-alternatives: --install needs <link> <name> <path> <priority>

Use 'update-alternatives --help' for program usage information.   

我是Ubuntu的新手,我不知道自己在做什么错.

I'm new to Ubuntu and Idon't know what I'm doing wrong.

推荐答案

打开.bashrc文件nano ~/.bashrc.在文件顶部的新行上键入alias python=python3,然后使用ctrl + o保存文件并使用ctrl + x关闭文件.然后,返回命令行输入source ~/.bashrc.现在,您的别名应该是永久的.

Open your .bashrc file nano ~/.bashrc. Type alias python=python3 on to a new line at the top of the file then save the file with ctrl+o and close the file with ctrl+x. Then, back at your command line type source ~/.bashrc. Now your alias should be permanent.

对于更新替代方案,优先级是整数.优先级表示应该首先使用哪个程序. 这篇文章总结得很好.

For update alternatives, the priority is an integer. The priority represents which program should be the first used. This article sums it all up pretty well.

这篇关于无法在ubuntu中将默认python版本设置为python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆