Python 2.5.6 on Ubuntu Natty... urgh...

Customer asked me to look at a 2.5 based project yesterday.  No problem, just fire up my virtualenv and take a quick look.  Hrm, no, the virtualenv isn't working... Python 2.5 isn't installed.  Hrm, and it's not in the apt repository for Natty.  Hrm... okay, build from source... fail on sqlite... debug... patch... build succeeds.  Hrm... altinstall succeeds, but no zlib module... debug... rebuild... debug... rebuild... blah just seems broken, no non-trivial software will install.  PPA of a backport... nope, not working, apt failures and a partially hosed apt (conflicts and all sorts of nasty issues).

2 un-billable hours trying to get a Python 2.5 install up, wound up having to use an old Debian machine with 2.5 installed (one of the customer's as it happens).  Seems I need to get a Python 2.5 virtual machine built.  3.x doesn't matter for my business, despite my having it available on all of my current machines; no one has ever asked for it. But not being able to run Python 2.5 (which customers actually want to use, and likey will for a few years) is costing me money.

Comments

  1. Eugene

    Eugene on 09/11/2011 7:18 p.m. #

    did you try PythonBrew?

  2. Nick Coghlan

    Nick Coghlan on 09/11/2011 7:58 p.m. #

    Sounds like another case of the Ubuntu multiarch layout breaking the default LDFLAGS settings in the Python build process. You may want to see if Christian's fix works for you:
    http://lipyrary.blogspot.com/2011/05/how-to-compile-python-on-ubuntu-1104.html

  3. Sébastien Douche

    Sébastien Douche on 09/11/2011 8:45 p.m. #

    Hi Mike,
    not sure to understand your problem w/o log but Ubuntu Natty introduces new directories for libraries and headers to support multiple architectures. Python's setup.py does not add the right paths, so some extensions won't build. See :

    http://bugs.python.org/issue9762
    http://bugs.python.org/issue11715

    Python 2.6/2.7 is patched, but Python 2.5 is closed to new patch.

    I suggest you to use Pythonbrew (http://pypi.python.org/pypi/pythonbrew). It add patches for you.

  4. Darren Yin

    Darren Yin on 09/11/2011 9:08 p.m. #

    A few months ago I was banging my head against the same wall, but I ultimately figured out a way to automate the process. I actually needed to install Python 2.5.2 (not even 2.5.6), but to do that I basically did

    sudo apt-get remove python
    sudo apt-get install libbz2-1.0 libc6 libdb4.8 libexpat1 libncursesw5 libreadline6 libsqlite3-0 mime-support libssl0.9.8 zlib1g
    (dependencies all found via
    http://packages.ubuntu.com/natty/python2.7
    http://packages.ubuntu.com/natty/python2.7-minimal
    )

    and then you're ready to build from source and install distribute and pip.

    There are some weird annoyances as well: I found I also had to
    sudo apt-get remove command-not-found
    because of some strange behavior involving pycentral.

    I don't know if it's the absolute correct way to make this stuff work, but I've been using it on production this way with basically no issues ever since. Just make sure to do everything through pip instead of Ubuntu.

  5. anon

    anon on 09/11/2011 9:58 p.m. #

    Use Debian.

    It never gonna let you out... (Rick Asley style)

  6. Kelly Black

    Kelly Black on 09/11/2011 10:08 p.m. #

    Mike,
    You just need to change the build options in the config file to get zlib (been there recently):

    in the source, edit Modules/Setup
    Change the zlib line to be included (i.e. remove the #).

    You should be golden after that. You can do a:
    make altinstall
    to get a python2.5 in the bin dir to call scripts instead of masking the python base install.

  7. Michael Dillon

    Michael Dillon on 09/11/2011 11:06 p.m. #

    It's time to recognize that the installed Python on Linux distros is part of the system and exists there mainly to support other parts of the system. It is not there for you and I to use as a development tool.

    The solution is to build your own Python distro tarball that you can install on any Linux distro. Here is my build script https://github.com/wavetossed/pybuild used on Ubuntu/Debian vms to build 2.7.2. Chances are it will build any other recent Python version as well.

  8. Ben Rousch

    Ben Rousch on 09/12/2011 7:15 a.m. #

    The correct way to get older and newer Pythons on Python is to use the DeadSnakes PPA

    https://launchpad.net/~fkrull/+archive/deadsnakes

    You just add the PPA following the instructions on that page, then apt-get install python2.5.

    I risk looking like an ass for mentioning it, but the first result on a Google search for 'python2.5 natty' would've pointed you in this direction.

  9. Mike Fletcher

    Mike Fletcher on 09/12/2011 8:35 a.m. #

    Actually, it was the deadsnakes PPA that I attempted to use; failed during installation.

  10. Ben Rousch

    Ben Rousch on 09/12/2011 8:47 a.m. #

    Interesting. I've never run into problems with it, but it looks like someone else had a little trouble. http://askubuntu.com/questions/40279/is-it-possible-to-install-python-2-5-in-11-04

  11. Mike Fletcher

    Mike Fletcher on 09/12/2011 9:03 a.m. #

    That was the missing piece. Apparently setup.py was *not* building the zlib module or finding the system-installed one (despite autoconf claiming it was going to use the system one). With that and patching setup.py to find the lib directory all installs and runs properly. Thanks!

  12. Mike Fletcher

    Mike Fletcher on 09/12/2011 9:05 a.m. #

    That would tend to destabilize my machine rather badly, as I use Python (2.7) for almost everything. The altinstall path is far better for me (I use virtualenvs for development work, so I don't need "python" to map into the system python).

  13. Mike Fletcher

    Mike Fletcher on 09/12/2011 9:07 a.m. #

    This was the patch I was using, but I apparently also needed to uncomment the module for zlib.

  14. Mike Fletcher

    Mike Fletcher on 09/12/2011 9:09 a.m. #

    I'd never actually heard of PythonBrew before. I can't say I'm a huge fan of the approach, I like keeping fairly close to "standard" installations whenever practical. Having to go through pythonbrew to get to Python just seems too invasive for something so low-level. Good to know about the project, though.

  15. Kelly Black

    Kelly Black on 09/12/2011 10:04 a.m. #

    You are welcome. Glad to be of help - you have helped me out with your blog posts in the past.

  16. David Grant

    David Grant on 09/12/2011 1:16 p.m. #

    Works for me on Natty and Maverick

Comments are closed.

Pingbacks

Pingbacks are closed.