我最近从20.04到21.04。问题是我有很多python
virtualenvs
使用python 3.8
未默认安装的。
我该如何修复它virtualenvs
才能让它再次工作?
sudo add-apt-repository ppa:deadsnakes/ppa
告诉我:
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/deadsnakes/ppa/ubuntu hirsute Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
和sudo apt-get update --allow-insecure-repositories
:
Reading package lists... Done
W: The repository 'http://ppa.launchpad.net/deadsnakes/ppa/ubuntu hirsute Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/dists/hirsute/main/binary-i386/Packages 404 Not Found [IP: 91.189.95.85 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
编辑:
因此,我尝试从源代码安装 3.8。我已经下载python 3.8.9.tgz
,现在要安装它 - 它会破坏最新版本吗?
答案1
这是完全不受支持,但对于大多数临时版本,您可以安装以前版本的软件包。这永远不能保证一定有效。例如,以前,我可以编辑sources.list.d
Groovy 的条目以引用 Focal,并且一切正常。
对于 Hirsute,由于系统 Python 是python3.9
,因此您需要格外小心,不要替换该软件包。您还需要执行一些额外的软件包固定步骤来避免这种情况。此外,Focal repo 不会提供python3.8
,因此您需要另一个 repo 和固定规则来从 Bionic 引入它。以下是设置,我更详细地写在这里。
/etc/apt/sources.list.d/deadsnakes.list
:
deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ focal main
deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ bionic main
/etc/apt/preferences.d/deadsnakes
:
Explanation: Prevent installing from deadsnakes repo.
Package: *
Pin: release o=LP-PPA-deadsnakes
Pin-Priority: 1
Explanation: Allow installing python 3.{6,7} from deadsnakes/focal
Package: *python3.6* *python3.7*
Pin: release o=LP-PPA-deadsnakes,n=focal
Pin-Priority: 500
Explanation: Allow installing python 3.8 from deadsnakes/bionic
Package: *python3.8*
Pin: release o=LP-PPA-deadsnakes,n=bionic
Pin-Priority: 500
请务必运行sudo apt update
以刷新存储库元数据,然后您应该能够安装其他 Python 包版本。
请注意,如果您选择这种方式,则意味着您同意在每次版本升级后审核所有存储库和固定规则,因为它们通常会被禁用。您还同意在搞砸事情时进行一些调试。请不要因为您在这样做时遇到的问题而打扰 deadsnakes 存储库维护者。他们不要支持非 LTS 版本。