先安装所需要的依赖
sudo yum -y groupinstall "Development tools" sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel sudo yum install -y libffi-devel zlib1g-dev sudo yum install zlib* -y sudo yum gcc
下载python的安装包
wget https://www.python.org/ftp/python/3.9.8/Python-3.9.8.tar.xz
不想下3.9.8的版本的话可以去python下载地址这里面找对应版本的安装包
解压
tar -xvJf Python-3.9.8.tar.xz
安装
cd Python-3.9.8 sudo ./configure --prefix=/usr/local/python3 sudo make sudo make install ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
测试是否安装成功
python3 -V pip3 -V