設置python版本:
1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100 2 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
切換python版本
1 sudo update-alternatives --config python
按照提示輸入編號即可
1 有 2 個候選項可用於替換 python (提供 /usr/bin/python)。 2 3 選擇 路徑 優先級 狀態 4 ------------------------------------------------------------ 5 * 0 /usr/bin/python3 150 自動模式 6 1 /usr/bin/python2 100 手動模式 7 2 /usr/bin/python3 150 手動模式 8 9 要維持當前值[*]請按<回車鍵>,或者鍵入選擇的編號:0 10 bing@bing-Lenovo:~/download$ python 11 Python 3.6.7 (default, Oct 25 2018, 09:16:13) 12 [GCC 5.4.0 20160609] on linux 13 Type "help", "copyright", "credits" or "license" for more information. 14 >>> exit()
這樣你甚至可以將自己喜歡的任意版本python安裝到任意位置,然后使用update-alternatives
將其設置為系統默認python