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
相关推荐
RSABLOCKCHAIN10 小时前
AI Agents in LangGraph-2
人工智能·python
WA内核拾荒者11 小时前
WhatsApp 账号异常检测的自动化告警系统设计
数据库·python·自动化
码流怪侠12 小时前
【GitHub】Bend:让 GPU 并行编程像写 Python 一样简单
python·github
2401_8949155313 小时前
GEO 搜索优化完整源码从零部署:环境配置、集群搭建全流程
开发语言·python·tcp/ip·算法·unity
zhiSiBuYu051714 小时前
Python3 模块开发与应用实战指南
python
databook15 小时前
用方差阈值过滤掉“惰性特征”
python·机器学习·scikit-learn
Freak嵌入式15 小时前
MCU 低功耗模式解析:时钟门控、电源门控、深度休眠
人工智能·python·单片机·嵌入式硬件·开源·依赖倒置原则·micropython
weixin_BYSJ198716 小时前
springboot校园自习室管理小程序---附源码32142
java·javascript·spring boot·python·django·flask·php
用户83562907805117 小时前
使用 Python 在 PDF 中绘制线条、矩形和自定义图形
后端·python