// 下载
wgethttps://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
// 解压
tar -zxvf Python-3.8.2.tgz
// 进入根目录
cd Python-3.8.2
// 安装
./configure --prefix=/opt/python --with-openssl=/usr/local --enable-optimizations
make && make install
// 建立软链
ln -s /opt/python/bin/python3.8 /usr/local/sbin/python3
ln -s /opt/python/bin/pip3.8 /usr/local/sbin/pip3
报错及处理
错误1
Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host()
处理1
# 下载安装libressl
wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz
tar -zxvf libressl-3.0.2.tar.gz
cd libressl-3.0.2
./configure --prefix=/usr/local
make && make install
# 确保lib下的libssl.so.47在ldconfig列表中,并更新
echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
ldconfig
ldconfig -v | fgrep libssl
错误2
Failed to build these modules: _ctypes
处理2
yum install libffi-devel -y