开发依赖包需要依赖于python3.11环境,但是目前python环境为3.6,于是需要修改python环境为3.11版本
Python 3.11 在 CentOS 7 中没有。我们将从源代码安装它
安装依赖包
yum -y update
systemctl reboot
yum -y install epel-release
yum install wget make cmake gcc bzip2-devel libffi-devel zlib-devel
#使用以下命令从包组安装所有开发工具
yum -y groupinstall "Development Tools"
#查看gcc版本
[root@master1 ~]#gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
安装 OpenSSL 1.1.1
#构建 Python 3.11 需要openssl 1.1.1或更新版本。系统存储库中可用的版本是旧的。
[root@master1 ~]#openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
#需要更新版本,安装依赖
yum install perl-core zlib-devel -y
#下载 OpenSSL 1.1.1 源码
cd /data/package
wget https://www.openssl.org/source/openssl-1.1.1.tar.gz
#解压
tar -zxf openssl-1.1.1.tar.gz
#配置和编译
cd openssl-1.1.1/
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib
make
make test
make install
#更新环境变量
vim /etc/profile
# OpenSSL 1.1.1
export PATH=/usr/local/openssl/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
#加载环境变量
source /etc/profile
#验证
[root@master1 openssl-1.1.1]#openssl version
OpenSSL 1.1.1 11 Sep 2018
#确保系统链接库指向正确的 OpenSSL 版本。
[root@master1 openssl-1.1.1]#sh -c "echo '/usr/local/openssl/lib' >> /etc/ld.so.conf"
[root@master1 openssl-1.1.1]#ldconfig
[root@master1 openssl-1.1.1]# mv /usr/bin/openssl /usr/bin/openssl.bak
[root@master1 openssl-1.1.1]#ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
安装python3.11
wget https://www.python.org/ftp/python/3.11.2/Python-3.11.2.tgz
tar xvf Python-3.11.2.tgz
cd Python-3.11.2/
#配置构建
LDFLAGS="${LDFLAGS} -Wl,-rpath=/usr/local/openssl/lib" ./configure --with-openssl=/usr/local/openssl
make
make altinstall
#检验
[root@master1 Python-3.11.2]#python3.11 --version
Python 3.11.2
[root@master1 Python-3.11.2]#pip3.11 --version
pip 22.3.1 from /usr/local/lib/python3.11/site-packages/pip (python 3.11)
#现在可以用pip安装任何模块
#测试
pip3 install virtualenv