debian12 安装python2.7
手动添加旧版本源并安装
添加 Debian 11(bullseye)的源(因为 Debian 11 仍包含 Python 2.7):
echo "deb http://deb.debian.org/debian bullseye main" | sudo tee /etc/apt/sources.list.d/bullseye.list
更新包索引(指定优先使用当前系统的源,避免大规模升级):
sudo apt update
安装 Python 2.7:
sudo apt install python2.7
验证安装:
python2.7 --version
安装 pip2(如果需要):
下载适用于 Python 2.7 的 get-pip.py
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
用 Python 2.7 安装 pip
sudo python2.7 get-pip.py
验证
pip2 --version
安装完成后,可注释掉 bullseye 源(编辑
/etc/apt/sources.list.d/bullseye.list

浙公网安备 33010602011771号