python3.10 安装
0. 我的环境
[root@ftp ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@ftp ~]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
[root@ftp ~]#
1. centos7.6 安装python3需要升级openssl
[root@ftp ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@ftp ~]# yum install -y ncurses-devel gdbm-devel xz-devel sqlite-devel tk-devel uuid-devel readline-devel bzip2-devel libffi-devel
[root@ftp ~]# yum install -y openssl-devel openssl11 openssl11-devel
[root@ftp ~]# openssl11 version
OpenSSL 1.1.1k FIPS 25 Mar 2021
2. 安装python3
python下载地址:https://www.python.org/ftp/python/
[root@ftp ]# mkdir -p /doc/temp && cd /doc/temp
[root@ftp temp]# wget https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz
#注意:编译时需要使用最新openssl库
[root@ftp Python-3.10.14]# export CFLAGS=$(pkg-config --cflags openssl11)
[root@ftp Python-3.10.14]# export LDFLAGS=$(pkg-config --libs openssl11)
#验证是否生效
[root@ftp Python-3.10.14]# echo $CFLAGS
-I/usr/include/openssl11
[root@ftp Python-3.10.14]# echo $LDFLAGS
-L/usr/lib64/openssl11 -lssl -lcrypto
[root@ftp temp]# tar xf Python-3.10.14.tgz
[root@ftp temp]# cd Python-3.10.14
#编译
[root@ftp Python-3.10.14]# ./configure --enable-optimizations && make altinstall
#配置软连接
[root@ftp Python-3.10.14]# ln -sf /usr/local/bin/python3.10 /usr/bin/python3
[root@ftp Python-3.10.14]# ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3
3. 查看python3版本
[root@ftp Python-3.10.14]# python3 --version
Python 3.10.14
[root@ftp Python-3.10.14]# pip3 --version
pip 23.0.1 from /usr/local/lib/python3.10/site-packages/pip (python 3.10)