Linux编译安装python312
跟着走就完了,简单的
不过网络问题没办法咯
#安装编译依赖
sudo yum update
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
#安装ssl
mkdir ~/tmp && cd ~/tmp
wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz
tar -zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w/
/config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
make && make install
#安装python
cd ~/tmp
wget https://www.python.org/ftp/python/3.12.10/Python-3.12.10.tar.xz
tar -xf Python-3.12.1.tar.xz
cd Python-3.12.1
./configure --with-openssl=/usr/local/openssl --prefix=/root/project/lee/Python-3.12.10
make
make install
#创建软链接
rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
sudo ln -s /root/project/lee/Python-3.12.10/bin/python3 /usr/bin/python3
sudo ln -s /root/project/lee/Python-3.12.10/bin/pip3 /usr/bin/pip3
#添加环境变量
echo "export PATH=/usr/bin/python3:/usr/bin/pip3:$PATH" >> ~/.bash_profile
source ~/.bash_profile
#测试
python3 --version
License:
CC BY 4.0