Centos7系统Python3.11.2版本安装

开发依赖包需要依赖于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
相关推荐
copyer_xyf29 分钟前
LangChain 调用 LLM
后端·python·agent
copyer_xyf38 分钟前
Prompt 组织管理
后端·python·agent
shimly1234561 小时前
python3 uvicorn 是啥?
python
CTA量化套保2 小时前
期货量化程序 time.sleep 卡死:天勤单线程与 deadline 替代
python·区块链
GIS数据转换器2 小时前
城市排水生命线安全运行监测平台深度解析
java·运维·人工智能·python·安全·数据挖掘·无人机
贤哥哥yyds3 小时前
GBK转UTF\-8编码自动转换工具 使用文档
python
数量技术宅3 小时前
2026量化前沿:从Reddit热帖到Python实战,如何用赫斯特指数(Hurst)狙击虚假突破?
开发语言·python
华如锦3 小时前
面了很多 Java转AI Agent方向,一些面试题总结
java·开发语言·人工智能·python·ai
戴西软件3 小时前
戴西 DLM 许可授权管理系统:破解无网络环境下工业软件授权难题,助力制造企业降本增效
网络·人工智能·python·深度学习·程序人生·算法·制造
Dxy12393102164 小时前
Python线程锁:为什么多线程会“打架“,以及怎么解决
开发语言·前端·python