Python 3.9.19 乌班图编译安装
1.安装工具链
sudo apt update
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev wget vim nano
2.拉取包
cd /home
mkdir -p Python
wget https://www.python.org/ftp/python/3.9.19/Python-3.9.19.tgz -P /home/Python/
3.解压
tar -xvf /home/Python/Python-3.9.19.tgz
4.编译
cd /home/Python/Python-3.9.19
./configure --enable-optimizations --prefix=/usr/local/python
make -j $(nproc)
# 使用所有可用CPU核心加速编译
sudo make altinstall
# 使用altinstall避免替换系统默认python3命令
rm -rf Python-3.9.19.tgz
5.软连接
sudo ln -s /usr/local/python/bin/python3.9 /usr/bin/python
sudo ln -s /usr/local/python/bin/pip3.9 /usr/bin/pip
6.更新pip版本
# 使用刚安装的pip3.9更新自身
pip install --upgrade pip