准备工作
yum install centos-release-scl
scl enable devtoolset-11 bash
wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz
编译
注意是在 scl 环境下进行的,gcc 版本过低的环境会导致编译失败
tar -zxf Python-3.12.4.tgz
cd Python-3.12.4
./configure --prefix=/usr/local/python3 --enable-optimizations --enable-shared --with-ssl
make && make install
链接
ln -s /usr/local/python3/bin/python3.12 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3.12 /usr/local/bin/pip3
echo '/usr/local/python3/lib' >> /etc/ld.so.conf.d/python.conf
ldconfig
测试
python3 -V
pip3 -V
标签:bin,python3.12,--,安装,3.12,centos7,usr,local,python3
From: https://www.cnblogs.com/huelse/p/18254915