views:

179

answers:

2

I'm trying to deploy a django project via mod_python and I keep getting an error saying a handler module is missing.

My apache config:

    <Location />
            SetHandler python-program
            PythonHandler django.core.handlers.modpython
            SetEnv DJANGO_SETTINGS_MODULE bookmarklet_server.settings
            PythonOption django.root /
            PythonDebug On
            #PythonPath "['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']"
    </Location>

The other path is from my attempt to just copy over the default pythonpath, but it didn't help.

A quick test in the python console shows the module should be accesible:

Python 2.6.4 (r264:75706, Nov 2 2009, 14:44:17) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information.

>>> import django.core.handlers.modpython

no errors

However loading the site, this error is inadvertendly returned:

MOD_PYTHON ERROR

ProcessId:      8926
Interpreter:    '<ip>'

ServerName:     '<ip>'
DocumentRoot:   '/htdocs'

URI:            '/'
Location:       '/'
Directory:      None
Filename:       '/htdocs'
PathInfo:       '/'

Phase:          'PythonHandler'
Handler:        'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1202, in     _process_target
    module = import_module(module_name, path=path)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 304, in import_module
    return __import__(module_name, {}, {}, ['*'])

ImportError: No module named django.core.handlers.modpython
A: 

Perhaps django isn't in your Pythonpath?

Lakshman Prasad
A: 

Ok, managed to fix the problem.

This particular import issue was fixed by installing django rather than just having the svn trunk linked into dist-packages. Why this doesn't work for server processes I don't know.

But anyway, there were further issues which were solved by doing a CGI deployment via nginx and eventually the last problem (which also failed my wsgi deployment attempt) was that my /home dir, which is where the files were, was accessible only by myself.

I learned a lot today :)

Swizec Teller