yum -y install zlib-devel bzip2-devel openssl-devel
yum -y install ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel xz-devel
yum -y install wget
yum install -y gcc #编译器
yum install libffi-devel -y
cd /opt
find /etc/ -name openssl.cnf -printf "%h\n"
--
/etc/pki/tls
# 3.x的版本在centos 8下安装不兼容
curl -O https://www.openssl.org/source/openssl-1.1.1m.tar.gz
tar zxvf penssl-1.1.1m.tar.gz
cd openssl-1.1.1m
./config --prefix=/usr/local/custom-openssl --libdir=lib --openssldir=/etc/pki/tls
make -j1 depend
make -j8 && make install_sw
popd
mkdir -p /usr/local/python3
cd /opt
wget https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz
tar xvf Python-3.10.2.tar.xz
cd Python-3.10.2
./configure -C --with-openssl=/usr/local/custom-openssl \
--with-openssl-rpath=auto --prefix=/usr/local/python3
make -j8
make altinstall
安装成功,提示如下
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
vim /etc/profile
---
export PATH=$PATH:/usr/local/python3/bin
--
# 生效
source /etc/profile
python3 -V
pip3 -V