溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

如何把Ubuntu16和18上的python升級(jí)到最新python3.8

發(fā)布時(shí)間:2021-05-19 14:03:44 來(lái)源:億速云 閱讀:558 作者:小新 欄目:開(kāi)發(fā)技術(shù)

小編給大家分享一下如何把Ubuntu16和18上的python升級(jí)到最新python3.8,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

1. 概述

本文記錄在 Ubuntu 16.04 上將 python 升級(jí)為 3.8 版本,并配置為系統(tǒng)默認(rèn) python3 的過(guò)程。

在 Ubuntu 16.04 中,python3 的默認(rèn)版本為 3.5:

$ python3 -V
Python 3.5.2

本文以在 Ubuntu 16.04 中安裝為例,方法同樣適用于 Ubuntu 18.04 。

2. 通過(guò) Apt 安裝

Ubuntu 官方 apt 庫(kù)中還未收錄 python 3.8,這里使用 deadsnakes PPA 庫(kù)安裝。

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 為系統(tǒng)默認(rèn) 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 默認(rèn)指向 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 測(cè)試 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

以上是“如何把Ubuntu16和18上的python升級(jí)到最新python3.8”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI