在Ubuntu 18.04上安裝Python 3.8可以通過以下步驟完成:
1.更新包列表和已安裝的包:
sudo apt update
sudo apt upgrade
2.安裝依賴項:
sudo apt install -y software-properties-common
3.添加Python 3.8的PPA(個人包歸檔)到你的源列表中:
sudo add-apt-repository ppa:deadsnakes/ppa
4.再次更新包列表以確保可以獲取PPA中的包:
sudo apt update
5.安裝Python 3.8:
sudo apt install -y python3.8
完成以上步驟后,Python 3.8將在你的Ubuntu 18.04系統上安裝成功。你可以通過運行python3.8
來確認安裝并使用它。
配置 python3.8 為系統默認 python3,將 python 各版本添加到 update-alternatives
$ which python3.8/usr/bin/python3.8$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1$ which python3.6/usr/bin/python3.6$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
配置 python3 默認指向 python3.8
$ sudo update-alternatives --config python3There are 2 choices for the alternative python3 (providing /usr/bin/python3).Selection Path Priority Status------------------------------------------------------------* 0 /usr/bin/python3.6 2 auto mode1 /usr/bin/python3.6 2 manual mode2 /usr/bin/python3.8 1 manual modePress to keep the current choice[*], or type selection number: 2
選擇/輸入?2
, 回車。
測試 python 版本
$ python3 -VPython 3.8.2