一、下载
替换Ubuntu16的阿里源,参考官方配置
apt-get upate
# 安装必要组件
apt-get install openssl htop iftop libssl-dev zlib1g-dev make gcc wget python3-pip
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tar.xz
二、解压
xz -d Python-3.6.9.tar.xz
tar -xvf Python-3.6.9.tar
三、安装
cd Python-3.6.9
#此处注意,一定要加上 --with-ssl参数,否则安装完成之后使用pip会出现ssl错误
./configure --with-ssl --prefix=/usr/bin/python3.6
make && make install
rm /usr/bin/python
ln -s /usr/bin/python3.6/bin/python3.6 /usr/bin/python
四、设置pip
rm /usr/bin/pip /usr/bin/pip3
ln -s /usr/bin/python3.6/bin/pip3 /usr/bin/pip