29

My project needs to stay current on Python releases, but 12.04LTS is currently stuck on 2.7.3, even though 2.7.5 is out now. Is there a way I can stay more current without manually compiling? We're required to stay on package-based installation for Python. What's the "right" way to handle this?

Thanks!

2 Answers 2

15

EDIT: *As @Anthon has pointed out in the comments, this PPA does not include Python 2.7 for Ubuntu 12.04 (Precise). See funky-future's answer below, which I don't believe existed when I originally responded.

The preferred "Ubuntu" way to deal with packages not included in their universe by default is to use a PPA (third party repository), rather than manually compiling. You maintain the benefits of package management, updates, and dependency resolution this way.

However, the third party repositories are NOT officially supported, if that is part of your requirement.

The DeadSnakes (get it) PPA maintains Python releases not included in the systems package management.

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

You can read more about this PPA here.

However, in your case this does not include Python 2.7, as DeadSnakes only provides major versions not included and not point releases. As Ubuntu already packages 2.7 for Ubuntu 12.04, DeadSnakes will not provide this.

It might be preferable for you to make the case that you should not use the native packaging with Ubuntu in this case. See this excerpt from 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.

If you are absolutely required to use the operating systems package management, and are unable to move to a different version of Ubuntu with a package provided by DeadSnakes, or natively, than you only have two options left, as I see it.

  1. You could request a backport of Python 2.7.5 to Ubuntu 12.04.
  2. You could create your own PPA with the version of Python you require.

side note: AskUbuntu is a better StackExchange to post stuff like this to, than SuperUser generally.

5
  • Perfect, thanks! In your experience, is DeadSnakes well maintained?
    – Will
    Jun 4, 2013 at 6:24
  • 2
    Yes, it does seem to be popular and well maintained. I'd have little reservation using it.
    – krondor
    Jun 8, 2013 at 13:09
  • 1
    It only has 2.7.4 for 10.04 not for 12.04
    – Anthon
    Jun 10, 2013 at 12:20
  • 1
    @Anthon you are correct, I didn't notice that. DeadSnakes will not replace a major release, so since Ubuntu already bundles Python 2.7, Deadsnakes will not provide point releases for that series. Rather they provide 3.3 for Precise. This will not help the OP in this case.
    – krondor
    Jun 13, 2013 at 17:45
  • On 14.04 I had to use ppa:fkrull/deadsnakes-python2.7 (note the suffix) May 1, 2017 at 21:56
38

Felix Krull also maintained (as in unmaintained now) a PPA with the latest Python 2.7 release for Ubuntu Precise, Trusty and Utopic. You can use the same process like krondor describes, but use instead or additionaly this 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
6
  • 1
    This should be the accepted answer. Jan 11, 2016 at 7:41
  • 2
    It has a "discontinued" warning now, but works nicely for machines which still run older Ubuntu versions. The PPA provides versions 2.7.12-1~precise1, 2.7.12-1~trusty1 and 2.7.10-0+utopic1 (for 12.04, 14.04 and 14.10).
    – mivk
    Nov 12, 2016 at 17:20
  • 6
    Just note that frull/deadsnakes-python2.7 ppa is discontinued. For the latest Python 2.7 releases(like 2.7.13), try use jonathonf/python-2.7 ppa.
    – socrates
    Jan 2, 2017 at 17:21
  • warning - this caused problems for me when upgrading distributions (12 -> 14).. I was left with a truly dead python.. Be sure to undo this ppa before upgrading..
    – dermen
    Apr 24, 2017 at 18:20
  • well, that's true for any distribution update and ppas. Apr 25, 2017 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .