BLOG

Sep 09 2009
Posted by chl @ 10:41am PDT

CentOS (and RHEL) 5 is great for some things, and not so great for others. What these distros do very well is never change. That’s their zen. If you get whatever it is you have working on them, then none of the official updates should ever break anything. They never bump versions, they just backport whatever security fixes are needed for as long as they support the release.

Unfortunately, that means you can get stuck using older than ideal software. For example, CentOS 5 ships with PHP 5.1.6, and Python 2.4. These are fine, but old. There’s new shiny hotness that developers want to use. That was largely why I set up my Yum repository. I wanted to make it easy to install PHP 5.3.0 on these CentOS machines.

Doing this for PHP was fairly easy. Doing something similar for Python is a lot harder, because a lot of the management software used on CentOS distros is written in Python and is version dependent. For example, Yum, which is used to managed all the packages on the system, is all Python. You can’t just upgrade Python or it’ll break all sorts of things. And yeah, that pretty much sucks. Especially since all my Django loving friends really want at least Python 2.5, and preferably Python 2.6.

So, I went ahead and did some annoying packaging work. My repository now has Python 2.6.2 packages that can be installed alongside the Python that ships with CentOS 5 and I don’t think will screw anything up. The binary is called

/usr/bin/python26

so you’ll need to invoke that to take advantage of it. I also made a mod_python26 package that will install an Apache module that uses the Python 2.6.2 stuff. So, if you’re doing Django, just install that module and Apache will use the new hotness. Conveniently, I also packaged Django 1.1, and the MySQL and PostgreSQL Python modules. And the memcached Python stuff, just for good measure.

If you have my repo installed, getting all this going should be as easy as

yum install python26 mod_python26 Django MySQL-python26

assuming you want to use MySQL for your database. I haven’t tested that on a clean install, so if you do and there’s problems please let me know. Also, if there are other Python libraries that folks need, let me know and I’ll see if I can make compatible packages.

Have fun.

18 Responses to “Easy Python 2.6 / Django on CentOS 5”

  1. Thanks for posting this info, Chris. Extremely helpful!

  2. mr krakatus says:

    I haven’t installed your repo yet but i shall right after posting this. Seems very helpful, especially for me at this moment. However, I didn’t see psycopg2 in your repo.. or did I miss something.. well that I can deal, thanks for being lazy :P .. or I wouldn’t get to have the repo

  3. dtady says:

    Hi Chris! Thanks for posting this. I have installed these python 2.6 rpms directly into my CentOS 5 bare VPS. I have a suggestion though:

    * python26-setuptools conflicts with python-setuptools
    * the python26-setuptools package could become more usable if you include a “/usr/bin/easy_install26″ binary.

    — below is easy_install26 script as taken from my ubutu box:

    #!/usr/bin/python26
    # EASY-INSTALL-ENTRY-SCRIPT: ‘setuptools==0.6c9′,’console_scripts’,'easy_install’
    __requires__ = ‘setuptools==0.6c9′
    import sys
    from pkg_resources import load_entry_point

    sys.exit(
    load_entry_point(‘setuptools==0.6c9′, ‘console_scripts’, ‘easy_install’)()
    )

  4. Hi Chris, thanks for wirting this post, I am sure it will be very handy. I just have one problem, when I run:

    # yum install python26 mod_python26 Django MySQL-python26

    I get the following:

    python26-2.6.2-2.i386 from chl has depsolving problems
    –> Missing Dependency: libffi.so.5 is needed by package python26-2.6.2-2.i386 (chl)
    python26-2.6.2-2.i386 from chl has depsolving problems
    –> Missing Dependency: libffi.so.5 is needed by package python26-2.6.2-2.i386 (chl)
    Error: Missing Dependency: libffi.so.5 is needed by package python26-2.6.2-2.i386 (chl)

    Do you have any insight into this?

    Thanks!

    Adam

  5. Jonathan says:

    @Adam

    I had the same problem. I got libffi.so.5 from

    ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/libffi-3.0.5-1.el5.kb.i386.rpm

    The install worked after that.

    Jon

  6. pulegium says:

    Hi Chris,

    Cheers for posting this and creating a repo.

    Just a note for those who want to create their own RPMs (for example to package fresh and new python :) ) I’ve created a quick guide how to package Python manually:

    http://www.grenadepod.com/2009/12/26/building-python-2-6-4-rpm-for-centos-5-4/

    Thanks!

  7. Frans says:

    Thanks for this info.
    For the missing dependencies I used the epel repository:
    http://fedoraproject.org/wiki/EPEL

  8. Andrew says:

    Hi Chris,

    Thanks for this info, and making your repos available.

    I’ve just tried this on a very very minimal clean 5.4 install and get the following error:

    Error: Missing Dependency: libffi.so.5 is needed by package python26-2.6.2-2.i386 (chl)

    Looks like libffi is needed, but that package isn’t available in any default CentOS repos. It’s available in the Fedora EPEL CentOS repos… you might want to note that.

    Cheers,

    Andrew

  9. Andrew says:

    Chris,

    Another thing… your version of python-setuptools breaks things like pip:

    [root@django /]# pip
    Traceback (most recent call last):
    File “/usr/bin/pip”, line 2, in ?
    import pip
    File “/usr/lib/python2.4/site-packages/pip.py”, line 6, in ?
    import pkg_resources
    ImportError: No module named pkg_resources

    Easy enough to fix this with a few links:

    cd /usr/lib/python2.4/site-packages/
    ln -s /usr/lib/python2.6/site-packages/pkg_resources*
    ln -s /usr/lib/python2.6/site-packages/pkg_resources.pyo
    ln -s /usr/lib/python2.6/site-packages/pkg_resources.pyc
    ln -s /usr/lib/python2.6/site-packages/pkg_resources.py

    Cheers,

    Andrew

  10. Sidney says:

    I updated Python on my CentOs5.4 system, everything checked out except I can’t seem to get YUM to work anymore. I read the faq but didn’t sort it out. Can you please help?

    thanks – sidney

    ————–

    [root@Linux /]# python -V
    Python 2.6.5
    [root@Linux /]# yum
    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

    No module named yum

    Please install a package which provides this module, or
    verify that the module is installed correctly.

    It’s possible that the above module doesn’t match the
    current version of Python, which is:
    2.6.5 (r265:79063, Apr 25 2010, 05:32:41)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]

    If you cannot solve this problem yourself, please go to
    the yum faq at:
    http://yum.baseurl.org/wiki/Faq

  11. Ben says:

    Hey sydney,
    I am far away from being a crack in CentOS, but it looks like for some reason std. pythong binary was replaced by the 2.6.x version. You should have a look of there is more than one binary available in /usr/bin or whereever it is supposed to be. just enter which python and look in the path that it returns.
    If other version of python is still there create a symlink in that place called python and link it to python 2.4.x version.

    Try a bit, but make sure to be able to revert back to the config now.

    Just an idea from a beginner of CentOS but a long time user of *nix.

  12. Ben Timby says:

    Chris, thanks for doing this.

    I just finished following your lead but for x86_64 and mod_wsgi. I also updated some of the RPMs, and built a bunch of other packages for python26-* libraries that my app needed.

    Maybe one of your readers will find my work useful!

    http://ben.timby.com/?p=123

  13. jack mullen says:

    Thank you Chris :

    The procedure was fast , easy and it worked !

  14. ed davison says:

    Just tried to update this (and thanks for the repo!) and am getting an error:

    mod_python26-3.3.1-11.i386 from chl has depsolving problems
    –> mod_python26 conflicts with mod_python
    Error: mod_python26 conflicts with mod_python
    You could try using –skip-broken to work around the problem
    You could try running: package-cleanup –problems
    package-cleanup –dupes
    rpm -Va –nofiles –nodigest
    The program package-cleanup is found in the yum-utils package.

  15. Matt Mah says:

    plus one on ed davidson’s error:

    ‘mod_python26 conflicts with mod_python’

    After removing mod_python26 from the list of packages the yum install went flawlessly.

    I am guessing that until I get mod_python26 installed I cannot take advantage of the 2.6 hotness with Django.

  16. derelict says:

    @ed & @matt — try removing mod_python first (unless you really need it in its current version), that cleared it for me. THANK YOU SO MUCH this was an easy workaround for my CentOS 5 install.

  17. heyu says:

    centos sucks nuts, using old ass crusty software because the devs believe that it is “stable” or “secure” is crap, that old GCC is worthless.

  18. Peter Hanley says:

    I worked around the easy_install problem (i.e. that easy_install installed to /usr/lib/python2.4/site-packages/) by doing


    alias easy26='sudo python26 /usr/lib/python2.6/site-packages/easy_install.py'

    and then installing libraries with easy26:

    easy26 python26-flickrapi

    The right way? Probably not? Did it work? Probably. ;-)

Leave a Reply

18 Comments

chrislea.com is proudly powered by wordpress
entries (rss) and comments (rss).

Switch to our mobile site