如何在 Ubuntu 12.04 LTS 上“正确”使用最新的 Python 2.7.x?

如何在 Ubuntu 12.04 LTS 上“正确”使用最新的 Python 2.7.x?

我的项目需要保持 Python 版本的最新状态,但 12.04LTS 目前停留在 2.7.3 上,尽管 2.7.5 现已发布。有没有办法让我保持最新状态而无需手动编译?我们需要继续使用基于软件包的 Python 安装。处理此问题的“正确”方法是什么?

谢谢!

答案1

编辑: *正如@Anthon在评论中指出的那样,此 PPA 不包含适用于 Ubuntu 12.04 (Precise) 的 Python 2.7。请参阅 funky-future 的回答以下,我不相信当我最初回应时它就存在。

处理默认情况下未包含在其范围内的软件包的首选“Ubuntu”方法是使用 PPA(第三方存储库),而不是手动编译。这样,您可以保留软件包管理、更新和依赖关系解析的好处。

然而,第三方存储库不是如果这是您的要求的一部分,则官方支持。

DeadSnakes(获取它)PPA 维护系统包管理中未包含的 Python 版本。

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python2.7

您可以阅读有关此 PPA 的更多信息这里

但是,对于您来说,这不包括 Python 2.7,因为 DeadSnakes 仅提供未包含的主要版本,而不是点发布。由于 Ubuntu 已经为 Ubuntu 12.04 打包了 2.7,因此 DeadSnakes 不会提供此版本。

在这种情况下,您可能更愿意提出不要使用 Ubuntu 的原生打包。请参阅 DeadSnakes 的摘录;

Using third-party modules packaged for Debian or Ubuntu with the Python
interpreters from this repository is a bit of a mixed bag. For Python 2, Python
modules from the official repositories will not work, as a consequence of how
Python packaging works in Debian. For Python 3 on the other hand, all
pure-Python module packages at least should be available; compiled extension
modules will not work however.

In general, you're better off installing Python modules using the common Python
packaging tools rather than the system package manager. For an introduction into
the Python packaging ecosystem and its tools, refer to;
    http://guide.python-distribute.org/

A few of these tools might also be provided in this repository as a convenience.

如果您确实需要使用操作系统包管理,并且无法使用 DeadSnakes 提供的包或本地提供的包迁移到不同版本的 Ubuntu,那么在我看来,您只剩下两个选择。

  1. 您可以请求将 Python 2.7.5 反向移植到 Ubuntu 12.04。
  2. 你可以创建自己的电力供应协议使用您需要的 Python 版本。

边注询问Ubuntu通常来说,是一个比 SuperUser 更好的 StackExchange 来发布这类内容。

答案2

菲利克斯·克鲁尔保持(目前未维护)适用于 Ubuntu Precise、Trusty 和 Utopic 的最新 Python 2.7 版本的 PPA。您可以使用与 krondor 描述的相同的过程,但改用或另外使用此 PPA:ppa:fkrull/deadsnakes-python2.7

sudo add-apt-repository ppa:fkrull/deadsnakes-python2.7
sudo apt-get update
sudo apt-get install python2.7

相关内容