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