1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #安装编译依赖 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
|