在Ubuntu 16.04.6 LTS上升级python 3.5到3.7

安装依赖库

sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev
sudo apt-get install liblzma-dev libffi-dev libc6-dev

从python官网下载
https://www.python.org/downloads/release/python-373/

wget ‘https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz’

tar zxvf Python-3.7.3.tgz

cd Python-3.7.3

sudo mkdir -p /usr/local/python3

./configure --prefix=/usr/local/python3 --enable-optimizations
make
sudo make install

删除软链接
先执行查看版本,如果有则证明软链接已存在,需要先删去以前的再重新建立
sudo rm -rf /usr/bin/python3
sudo rm -rf /usr/bin/pip3

建立新的软连接
#添加python3的软链接
sudo ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
#添加 pip3 的软链接
sudo ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

检测版本
python3 -V
pip3-V

pip3报错查看另一篇

你可能感兴趣的:(在Ubuntu 16.04.6 LTS上升级python 3.5到3.7)