CentOS 7 看这个
https://blog.csdn.net/fullbug/article/details/121146117
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
更新pip
sudo apt-get install python3-pip
pip3 install --upgrade pip
pip3 -V
下载
wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tar.xz
xz -d Python-3.8.11.tar.xz
tar -xvf Python-3.8.11.tar
编译
./configure prefix=/usr/local/python3
sudo -s
sudo make altinstall //不要使用标准的make install,因为它将覆盖默认的系统python3二进制文件
软连接
# 设置新的软链接
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip