views:

322

answers:

2

In a harrowing attempt to get mod_wsgi to run on CentOS 5.4, I've added python 2.6 as an optional library following the instructions here. The configuration seems fine except that when trying to ping the server the Apache log prints this error:

mod_wsgi (pid=20033, process='otalo', application='127.0.0.1|'): Loading WSGI script '...django.wsgi'. [Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] mod_wsgi (pid=20033): Target WSGI script '...django.wsgi' cannot be loaded as Python module. [Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] mod_wsgi (pid=20033): Exception occurred processing WSGI script '...django.wsgi'. [Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] Traceback (most recent call last): [Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] File "...django.wsgi", line 8, in [Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] import django.core.handlers.wsgi [Sat Mar 27 16:11:45 2010] [error] [client 171.66.52.218] ImportError: No module named django.core.handlers.wsgi

when I go to my python2.6 install's command line and try 'import django', the module is not found (ImportError). However, my default python 2.4 installation (still working fine) is able to import successfully. How do I point python 2.6 to django?

Thanks in advance.

A: 

You need to install Django specifically with/for the Python version that's meant to use it -- installs for 2.4 and 2.6 are always going to be separate (they have to be -- there are incompatibilities in binary and bytecode formats!). I don't know what, if any, possibilities CentOS offers for that -- I'd get Django's sources and install from sources (which boils down to: download, tar, cd, and finally a simple sudo python2.6 setup.py install -- or however else you run your 2.6 install of Python). Being a much better developer than I'm a system administrator, I always have a bias in favor of installing from sources for stuff that's really at the core of what I'm doing (especially Python versions and extensions).

Alex Martelli
That did it, thanks!By the same logic I have to now go back and install other python plugins for the parallel install (MySQLdb, wadofstuff serializers, etc.)
NP
@NP, right -- each Python version needs its own installs. (Other Linux distros such as Ubuntu tend to be pretty up-to-date with current versions of Python and its extensions, but I get the impression that CentOS does not). BTW, fundamental SO etiquette is "thanks are nice, but accepts are crucial" -- I see you have a 0% accept rate so may not know that (to accept an answer, click the checkmark-shaped icon below the number on the answer's left). Accepting gives you +2 rep, and at 15 you can also do upvotes, which are also core to the working of Stack Overflow.
Alex Martelli
A: 

I created a write up link text of my experiences of getting Django working on Redhat and and CentOS. I upgraded the version of python that I was using and started with init.d scripts.

timc3