ubuntu16.04修改Python默认版本

Ubuntu16.04 默认python版本是Python2,但也可以修改默认的Python版本

 sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 
 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150 
 备注:输入--install时,需注意是两个连续的‘-’;

fyy@ubuntu:~$ python

Python 3.5.2 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

如果想要重新设置为python2,可以执行一下命令:
sudo update-alternatives –config python

There are 2 choices for the alternative python (providing /usr/bin/python).
  Selection    Path              Priority   Status
-----------------------------------------------------------
* 0            /usr/bin/python2   100       auto mode
  1            /usr/bin/python2   100       manual mode
  2            /usr/bin/python3   150       manual mode
Press  to keep the current choice[*], or type selection number: 0(输入对应的选择编号,此处我选择的是0)

你可能感兴趣的:(工具类,python)