1预先安装基础包
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel postgresql-devel* gcc-c++ libstdc++-devel
2 下载python3源码(我这里是v3.8.9 需要可以按需下载)
wget https://www.python.org/ftp/python/3.8.9/Python-3.8.9.tgz
3 解压压缩包
tar -zxvf Python-3.8.9.tgz
4 编译
cd Python-3.8.9
./configure
make
make install
5 查看是否安装完成
/usr/bin/lib/python3.8
6 设置软链
cd /usr/bin
rm -f python
ln -s /usr/local/bin/python3.8 python
解决安装python3之后,yum无法使用,需要对 /usr/bin/yum 文件中的
#!/usr/bin/python
修改为
#!/usr/bin/python2