一、安装编译所需要的组件
sudo apt update
sudo apt install make build-essential libssl-dev zlib1g-dev liblzma-dev
sudo apt install libbz2-dev libreadline-dev libsqlite3-dev llvm
sudo apt install libncurses5-dev libncursesw5-dev xz-utils tk-dev
二、下载最新版的Python源文件包编译安装
# 解压缩
tar -xvf Python-3.8.x.tgz
# 切换到解压缩后的文件夹下
cd Python-3.8.x
# 执行configure配置构件文件
./configure --enable-optimizations --with-ssl
# 编译
make -j8
# 安装
sudo make altinstall
# 安装后的清理
sudo make clean
sudo apt autoremove
# 检查是否正常安装
python3.8 -V