Ubuntu 16.04 更新 Python 3.7

Jerry Kao
Jerry Kao
Sep 6, 2018 · 1 min read

有空可以先參考下面這份官方文件了解一下

1.裝下面這些套件

sudo apt-get install -y build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev zlib1g-dev openssl libffi-dev python3-dev python3-setuptools wget

2.開始安裝

# Prepare to build
mkdir /tmp/Python37
cd /tmp/Python37
# Pull down Python 3.7, build, and install
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz
cd /tmp/Python37/Python-3.7.0
./configure --enable-optimizations
sudo make altinstall

安裝後會在usr/local/bin 下面看到Python3.7的資料夾,就可以把tmp下面的資料夾移除了

https://www.jianshu.com/p/ea6c4758dba4 ->usr/local/bin跟usr/bin的差別

3.讓python3,pip3指令可以 mapping到 python3.7,pip3.7 (optional)

加下面二行到~/.bashrc :

重開terminal確認結果

python3 -V
Python 3.7.0

k2shouai

Rookie programmer

Jerry Kao

Written by

Jerry Kao

k2shouai

k2shouai

Rookie programmer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade