
我已經升級到 Ubuntu 21.04,因為我不想使用 LTS 版本(即有更高版本的軟體包)。我一直在使用預設的 Python 3.9 愉快地開發新的程式碼庫
但對於在 Python 3.6 上運行的較舊項目,我還想安裝 3.9 之前的版本(我遇到了圍繞版本 3.9 的打包問題)https://github.com/hzdg/django-enumfields/commit/8a54ab6ca1a406b4f736b1d8a1daff49431a1c5c但我更願意根據需要為我的 virtualenv 提供 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
.