我已升级到 Ubuntu 21.04,因为我不喜欢使用 LTS 版本(即使用较新的软件包)。我一直在使用默认的 Python 3.9 愉快地开发新的代码库
但对于在 Python 3.6 上运行的旧项目,我还想安装 3.9 之前的版本(我遇到了 3.9 版本相关的打包问题https://github.com/hzdg/django-enumfields/commit/8a54ab6ca1a406b4f736b1d8a1daff49431a1c5c但我更愿意根据需要为我的虚拟环境提供 3.6 或 3.7,而不是为目前在 3.6 上运行的代码库添加 3.9 特定的修复程序)。
我已经安装了 deadsnakes ppasudo add-apt-repository ppa:deadsnakes/ppa
并进行了更新。但是,当我尝试安装较早的 python 版本时,我遇到了依赖问题(可能是因为它是一个焦点包)
sudo apt-get install python3.7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python3.7 : Depends: libpython3.7-stdlib (= 3.7.12-1+focal1) but it is not installable
E: Unable to correct problems, you have held broken packages.
答案1
你应该自己编译它。使用:
sudo apt-get install libssl-dev openssl
wget https://www.python.org/ftp/python/<version>/Python-<version>.tgz
tar xzvf Python-<version>.tgz
cd Python-<version>
./configure
make
while<version>
是有效的 Python 版本,例如3.7.0
。