1. 程式人生 > >ubuntu16.04修改Python預設版本

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時,需注意是兩個連續的‘-’;

[email protected]:~$ 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 <enter> to keep the current choice[*], or type selection number: 0(輸入對應的選擇編號,此處我選擇的是0)