当前位置: 首页>>技术教程>>正文


linux – 如何在Ubuntu 12.04 LTS上使用最新的Python 2.7.x “The Right Way”?

, , ,

问题描述

我的项目需要在Python版本上保持最新,但是12.04LTS目前仍停留在2.7.3上,即使现在已经发布了2.7.5。有没有办法可以在不进行手动编译的情况下保持最新状态?我们需要继续使用基于软件包的Python安装。 “right”的处理方式是什么?

谢谢!

最佳回答

编辑:*正如@Anthon在评论中指出的那样,此PPA不包括适用于Ubuntu 12.04(精确)的Python 2.7。请参阅funky-future的答案below,我最初回答时不认为该答案存在。

默认情况下,处理未包含在其Universe中的程序包的首选”Ubuntu”方法是使用PPA(第三方存储库),而不是手动编译。您可以通过这种方式维护程序包管理,更新和依赖性解析的好处。

但是,如果这是您要求的一部分,则不正式支持第三方存储库。

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

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

您可以阅读有关此PPA here的更多信息。

但是,在您的情况下,它不包括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版本创建自己的PPA

旁注:通常,AskUbuntu是比SuperUser更好的StackExchange,可以将此类内容发布到其中。

次佳回答

Felix Krull还使用针对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

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/11212.html,未经允许,请勿转载。