Python3.11的Linux源码:
Index of /ftp/python/https://www.python.org/ftp/python/由于Centos7里自带的openssl是1.0版本的,而Centos Stream8和9用的是openssl-1.1.1版本的。
注意:openssl必须是openssl-1.1.1版本的,虽然最高版本已经到了3.x,但是必须用openssl-1.1.1版本的,否则会出现如下错误:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
1、安装openssl1.1.1,替换掉旧的openssl
下载网址:
[ Downloads ] - /source/index.htmlhttps://www.openssl.org/source/
tar -zxvf openssl-1.1.1w.tar.gz
二、编译安装
在以后所有操作之前必须执行以下操作,不然会失败,需要安装好编译环境:
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install libffi-devel -y
cd openssl-1.1.1w
指定安装路径并编译
编译前需要:
yum install perl-IPC-Cmd -y
yum install -y gcc
然后编译:
./config --prefix=/usr/local/openssl
make && make install
三、替换当前系统的旧版本 openssl 「先保存原来的」
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib64/openssl /usr/lib64/openssl.old
mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
四、最后查看当前系统 openssl 版本
openssl version
五、编译Python3.11
cd Python-3.11.7
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
六、重启后验证
完成!!!!!!