下载python3
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
安装python3
mkdir -p /usr/local/python3
mv Python-3.6.8.tgz /usr/local/python3
tar -zxvf Python-3.6.1.tgz
进入解压目录,编译安装
cd Python-3.6.8
apt-get install libssl-dev
vi Modules/Setup.dist
编辑如下:
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
./configure
make && make install
建立python3的软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
并将/usr/local/python3/bin加入PATH
vim ~/.bashrc
export PATH=$PATH:$HOME/bin:/usr/local/python3/bin
source ~/.bashrc
检验
Python3 -V
pip3 -V