1、下载python39
https://mirrors.huaweicloud.com/python/3.9.0/Python-3.9.0.tgz
2、拷贝到Linux环境(当然也可以直接在Linux环境使用wget直接下载)
先安装一下依赖,不然编译会有问题
bash
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 libffi-devel
3、安装
bash
tar -zxvf Python-3.9.0.tgz
配置安装路径
bash
cd Python-3.9.0/
./configure prefix=/usr/local/python39
编译并安装
bash
make && make install
添加软链接
bash
ln -sf /usr/local/python39/bin/python3 /usr/bin/python3
验证
bash
python3 --version