apt 拒绝安装更新版本的软件包

apt 拒绝安装更新版本的软件包

我正在尝试安装 Python 3.9,但 Debian 附带了 3.7。

当我运行时sudo apt install python3.9,我收到以下信息:

E: Unable to locate package python3.9
E: Couldn't find any package by glob 'python3.9'
E: Couldn't find any package by regex 'python3.9'

当我跑步时sudo apt install python3,我得到这个:

python3 is already the newest version (3.7.3-1).

我手动去发现Debian的服务器上实际上有Python 3.9。它位于这里

然后我下载了debPython 3.9 的文件并运行sudo apt install ./python3.9*,结果如下:

Note, selecting 'python3.9' instead of './python3.9_3.9.6-1_i386.deb'
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.9 : Depends: python3.9-minimal (= 3.9.6-1) but it is not installable
             Depends: libpython3.9-stdlib (= 3.9.6-1) but it is not installable
E: Unable to correct problems, you have held broken packages.

然后,我下载了deb这两个文件并尝试了相同的操作,但最终得到了更多“不可安装”的依赖项。

我知道您无法安装未针对我正在运行的 Debian 版本配置的软件包,但是有没有办法安装 Python 3.9?有没有办法在不从源代码构建的情况下安装它?

我正在运行buster带有 i386(32 位)架构的 Debian 10.10 ( )。

我的sources.list(我使用的是澳大利亚镜像):

deb http://ftp.au.debian.org/debian/ buster main
deb-src http://ftp.au.debian.org/debian/ buster main

deb http://ftp.au.debian.org/debian/ buster/updates main
deb-src http://ftp.au.debian.org/debian/ buster/updates main

# buster-updates, previously known as 'volatile'
# deb http://ftp.au.debian.org/debian/ buster-updates main
# deb-src http://ftp.au.debian.org/debian/ buster-updates main

答案1

你可以看到从Debian 的跟踪器那:

  • Debian 9 ( stretch/ oldstable) 随 3.5.3 一起发布
  • Debian 10 ( buster/ stable) 附带 3.7.3
  • Debian 11 ( bullseye/ testing) 将随 3.9.2 一起发布
  • experimental有3.9.4
  • python3不可用于stable-backports

bullseye将在几周内发布。如果你执行dist-upgradeto bullseye,你将得到 python3.9。这是你能做的最安全的事情。

可以添加experimental到您的souces.list, 然后sudo apt install -t experimental python3,但是您正在替换一个非常核心的软件包,如果事情进展不顺利,那么它可能会存在一些危险。

另请注意:如果您使用的是 Debian 10,则所有本机软件包都可以与 python3.7 一起使用。除非您自己编写 Python 代码并且特别想使用新版本提供的功能,否则几乎没有理由升级。如果您依赖pip软件包,那么大多数软件包都可以python3-<pkg>在 Debian 10 中与 python3.7 一起使用。

答案2

用非标准版本替换系统 python 是一个非常糟糕的主意,并且很有可能破坏您的系统。最好升级整个系统以获取更新的 python,或者在另一个目录中安装单独的 python。

如果你确实需要不同版本的 python,而不是替换系统 python,你应该考虑在你的主目录中安装类似 anaconda 的东西。

然而,这又带来了多个 python 版本可用的问题,你需要小心你总是运行你期望的 python。

相关内容