ubuntu 16.04 安裝 python3.6

檢查已安裝的 python 版本

在 terminal 中

python -V
顯示 Python 2.7.12
python3 -V
顯示 Python 3.5.2

安裝依賴(lài)(可選)

若跳過(guò)這一步,可能在使用 python3.6 解釋器的 virtualenv 中, pip 安裝第三方包失敗。
通過(guò) apt-get 安裝依賴(lài)

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

下載 python 3.6 源代碼

前往 python 官網(wǎng),進(jìn)入下載頁(yè)面 —— 源代碼, 點(diǎn)擊最新的 python 版本。(此時(shí)為 3.6.5)


image.png

在新打開(kāi)的頁(yè)面最底部,右鍵第一項(xiàng) Gzipped source tarball ,復(fù)制鏈接地址。


image.png

打開(kāi) terminal , 切換到 opt 目錄,用 wget 下載剛復(fù)制的鏈接。
cd /opt
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz

解壓
tar -xvf Python-3.6.5.tgz
會(huì)解壓到名為 Python-3.6.5 的文件夾。

安裝 python 3.6

切換到解壓出來(lái)的 Python-3.6.5 目錄,然后依次執(zhí)行命令進(jìn)行安裝。(可能需要 sudo)

cd /opt/Python-3.5.6
./configure
make
sudo make install

python 3.6 的解釋器會(huì)安裝在 /usr/local/bin/python3.6 。安裝完成后 python3 命令會(huì)指向 python 3.6 解釋器,如下列命令所示。

python3.6 -V
顯示 Python 3.6.5
python3 -V
顯示 Python 3.6.5

python3.5 版本可用 python3.5 調(diào)用

python3.5 -V
顯示 Python 3.5.2
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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