SystemError: dynamic module not initialized properly is an exception that is thrown when the dll (or .so) that is loaded cannot be correctly initialized. In the _PyImport_LoadDynamicModule of Python/importdl.c in case someone is interested.
Now, the dll / so in question (dynamic module in Python parliance) is _functools.so , which is part of the Python standard library. I see that it is loading from / opt / python 2.6, so we know that this is not system python. I assume this is not the python mod_wsgi was compiled with. To check if this is running, run ldd mod_wsgi.so and see what libpython returns.
So my suggestion is to recompile the mod_wsgi againast interpreter in / opt / python 2.6 by running wsgi_mod in the source directory
./configure --with-python=/opt/python2.6/bin/python2.6
or make sure sys.prefix points to the python installation that mod_wsgi expects by setting its value to the WSGIPythonHome directory.
UPDATE after ldd is released
The second line in the ldd output shows that mod_wsgi loads pythonlib in /usr/lib instead of /opt/python2.6 . To instruct mod_wsgi to load this value in /opt/python2.6 , you should probably add it to the LD_LIBRARY_PATH envirnoment variable.
Try it first on the command line:
LD_LIBRARY_PATH=/opt/python2.6/lib:$LD_LIBRARY_PATH ldd mod_wsgi.so
and then make sure the script that starts Apache has the correct LD_LIBRARY_PATH.
Another update
You will have to debug the mod_wsgi configuration. Just try with the following .wsgi file instead of yours and tell us what you get:
def application(environ, start_response): status = '200 OK' start_response(status, [('Content-type', 'text/plain')]) try: import sys return ['\n'.join([sys.prefix, sys.executable])] except: import traceback as tb return [tb.format_exc()]
If you are not getting `/opt/python2.6 ', try with the option
WSGIPythonHome /opt/python2.6
See also http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives