以安装python3.9为例,其他版本同理


安装python3.9

下载python3.9并编译安装

wget https://www.python.org/ftp/python/3.9.10/Python-3.9.10.tgz

tar -xvf Python-3.9.10.tgz

cd Python-3.9.10
./configure --prefix=/usr/local/python3

make
make altinstall

添加以下内容到/etc/profile

export PATH="/usr/local/python3/bin:$PATH"
source /etc/profile