Centos安装python3
[python官网] https://www.python.org/downloads/
安装预备环境
#安装源码编译需要的编译环境
yum install gcc zlib zlib-devel libffi libffi-devel make
yum install bzip2-devel xz-devel sqlite-devel tk-devel uuid-devel ncurses-devel
#解决后期出现的方向键、删除键乱码问题
yum install -y readline-devel
#
yum install -y wget
安装openssl
# openssl所需要的依赖
yum -y install perl perl-CPAN
#安装 IPC::Cmd模块,此过程会有几次交互,直接按y即可
cpan IPC::Cmd
#下载openssl
wget https://www.openssl.org/source/openssl-3.0.14.tar.gz
#解压
tar -xzvf openssl-3.0.14.tar.gz
#配置
cd openssl-3.0.14
./config --prefix=/usr/local/openssl3.0.14 --libdir=lib --openssldir=/etc/ssl
#编译
make -j1 depend
make -j8
#安装
make install_sw
安装python
#解压
tar -zxvf Python-3.10.13.tgz
#配置
cd Python-3.10.13
./configure --with-openssl=/usr/local/openssl3.0.14 --with-openssl-rpath=auto --prefix=/usr/local/python3.10
#编译
make -j8
#安装
make altinstall
#建软链
ln -s /usr/local/python3.10/bin/python3.10 /usr/bin/python3
ln -s /usr/local/python3.10/bin/pip3.10 /usr/bin/pip3
#验证
python3 --version
pip3 --version