在Linux上升級Python版本

  1. 首先可以使用以下命令查看當(dāng)前的python版本:
python3 -V
  1. 安裝最新版python, 以python 3.8為例:
apt update
apt install python3.8
  1. 將原版本的python和python3.8添加到update-alternatives中:
 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6  1
 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8  2
#可以使用 whereis python3 命令在linux中確定python的目錄
#上述命令結(jié)尾的數(shù)字代表優(yōu)先級, 系統(tǒng)跟據(jù)優(yōu)先級選擇默認(rèn)的python版本
  1. 可以跟據(jù)需要自由切的python3命令的指向:
 update-alternatives --config python3

auto mode是跟據(jù)優(yōu)先級自動(dòng)選擇.

root@markict:~# update-alternatives --config python3 
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8   2         auto mode
  1            /usr/bin/python3.6   1         manual mode
  2            /usr/bin/python3.8   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 0
  1. 版本升級成功:
python3 -V
root@markict:~# python3 -V
Python 3.8.0
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容