第一步:安装扩展依赖包:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
yum -y install epel-release
yum install python-pip
第二步:官方查看并下载对应稳定版本
下载路径扩展:https://www.python.org/downloads/source/
wget https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tgz
tar -zxvf Python-3.9.4.tgz
cd Python-3.9.4
./configure prefix=/usr/local/python3 --enable-optimizations
make && make install
#添加python3的软链接 注意centos本身自带python,软连接名称可以改为python3 ,直接改为python可能会冲突
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
#测试是否安装成功了
python -V