將 Ubuntu 16 和 18 上的 python 升級到最新 python3.8 的方法教程
阿新 • • 發佈:2020-03-12
1. 概述
本文記錄在 Ubuntu 16.04 上將 python 升級為 3.8 版本,並配置為系統預設 python3 的過程。
在 Ubuntu 16.04 中,python3 的預設版本為 3.5:
$ python3 -V
Python 3.5.2
本文以在 Ubuntu 16.04 中安裝為例,方法同樣適用於 Ubuntu 18.04 。
2. 通過 Apt 安裝
Ubuntu 官方 apt 庫中還未收錄 python 3.8,這裡使用deadsnakes PPA 庫安裝。
2.1. 安裝依賴包
$ sudo apt update $ sudo apt install software-properties-common
2.2. 新增 deadsnakes PPA 源
$ sudo add-apt-repository ppa:deadsnakes/ppa
Press [ENTER] to continue or Ctrl-c to cancel adding it.
2.3. 安裝 python 3.8
$ sudo apt install python3.8
$ python3.8 -V
Python 3.8.2
3. 配置 python3.8 為系統預設 python3
3.1. 將 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.5 /usr/bin/python3.5 $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 2
3.2. 配置 python3 預設指向 python3.8
$ sudo update-alternatives --config python3 There are 2 choices for the alternative python3 (providing /usr/bin/python3). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.5 2 auto mode 1 /usr/bin/python3.5 2 manual mode 2 /usr/bin/python3.8 1 manual mode Press <enter> to keep the current choice[*],or type selection number: 2
選擇/輸入 2,回車。
3.3 測試 python 版本
$ python3 -V
Python 3.8.2
資源
How to Install Python 3.8 on Ubuntu 18.04
How to upgrade to python 3.7 on Ubuntu 18.10
總結
到此這篇關於將 Ubuntu 16 和 18 上的 python 升級到最新 python3.8 的方法教程的文章就介紹到這了,更多相關 Ubuntu 16 和 18 升級到python 3.8 內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!