[Ubuntu] 在 Ubuntu 16.04 上安裝 Python 3.6
Ubuntu 16.04 上預設的 Python 是 3.5,
不過公司專案用到的是 Python 3.6,
想要快速的安裝 Python 3.6,要怎麼做呢?
當然一個方法是抓原始碼來編譯,
不過爬了一下文,也可以用別人已經建好的套件庫來直接安裝~
先安裝相關套件:
apt-get install software-properties-common python-software-properties
再加入別人的套件庫:
add-apt-repository ppa:jonathonf/python-3.6 add-apt-repository ppa:deadsnakes/ppa
接著就可以直接安裝 Python 3.6:
apt-get update apt-get install python3.6
安裝好之後,python3 其實還是指向 python3.5 的:
root@localhost ~ # ll /usr/bin/python* lrwxrwxrwx 1 root root 9 Feb 18 17:48 /usr/bin/python -> python2.7* lrwxrwxrwx 1 root root 9 Feb 18 17:48 /usr/bin/python2 -> python2.7* -rwxr-xr-x 1 root root 3488528 Oct 6 02:03 /usr/bin/python2.7* lrwxrwxrwx 1 root root 9 Feb 18 17:48 /usr/bin/python3 -> python3.5* lrwxrwxrwx 1 root root 16 Mar 23 2016 /usr/bin/python3-config -> python3.5-config* -rwxr-xr-x 2 root root 4460304 Oct 10 00:55 /usr/bin/python3.5* lrwxrwxrwx 1 root root 33 Oct 10 00:55 /usr/bin/python3.5-config -> x86_64-linux-gnu-python3.5-config* -rwxr-xr-x 2 root root 4460304 Oct 10 00:55 /usr/bin/python3.5m* lrwxrwxrwx 1 root root 34 Oct 10 00:55 /usr/bin/python3.5m-config -> x86_64-linux-gnu-python3.5m-config* -rwxr-xr-x 2 root root 4727904 Aug 18 2020 /usr/bin/python3.6* -rwxr-xr-x 2 root root 4727904 Aug 18 2020 /usr/bin/python3.6m* lrwxrwxrwx 1 root root 10 Feb 18 17:48 /usr/bin/python3m -> python3.5m* lrwxrwxrwx 1 root root 17 Mar 23 2016 /usr/bin/python3m-config -> python3.5m-config*
如果想讓 python3 執行到的是剛裝好的 python3.6,
可以重新設定符號連結 (symbolic link):
cd /usr/bin ln -sf python3.6 python3
這樣子 python3 跑的就會是 python3.6 了:
root@localhost ~ # python3 --version Python 3.6.12
參考資料:install python 3.6 on ubuntu 16.04
(本頁面已被瀏覽過 1,423 次)