1、Python源代码编译安装
1.1 下载源码:
https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz
1.2 安装开发工具
yum install gcc gcc-c++ openssl-deve
yum install zlib zlib-devel
1.3 编译
tar xf Python-3.11.2.tgz
#进入解压后的目录,依次执行下面命令进行手动编译
cd Python-3.11.2
./configure prefix=/usr/local/python3
make && make install
1.4 添加软连接
#添加python3的软链接
ln -s /usr/local/python3.5/bin/python3 /usr/bin/python3
# 添加pip3
ln -s /usr/local/python3.5/bin/pip3 /usr/bin/pip3
1.5 测试
python3 -V
pip3 -V
报错:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
发现是openssl的版本太低了,升级
2、openssl源代码编译安装
2.1 openssl 官方下载地址:https://www.openssl.org/source/
wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz
2.1 编译
tar -zxvf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t
./config --prefix=/usr/local/openssl // 指定安装路径
make && make install
#备份旧的,并且建立软连接
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 version
2.2重新编译python
cd Python-3.11.2
./configure prefix=/usr/local/python3
make && make install