views:

1193

answers:

2

I have had django running with mod_python for awhile now but today I get the following error

MOD_PYTHON ERROR

ProcessId:      4551
Interpreter:    'thatch'

ServerName:     'thatch'
DocumentRoot:   '/var/www/thatch'

URI:            '/'
Location:       '/'
Directory:      None
Filename:       '/var/www/thatch/'
PathInfo:       ''

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

Traceback (most recent call last):

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

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

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

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

This is my virtual host configuration

<VirtualHost *:80>
  ServerName  thatch

  DocumentRoot /var/www/thatch

  <Location "/">
    SetHandler python-program
    PythonPath "['/var/www/thatch'] + sys.path"
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE thatch.settings
    PythonOption django.root /var/www/thatch
    PythonDebug On
  </Location>

  <Location "/media">
    SetHandler None
  </Location>

  <LocationMatch "\.(jpg|gif|png|css|js)$">
    SetHandler None
  </LocationMatch>

</VirtualHost>

Any ideas why this is happening?

A: 

I can only guess what your problem might be, but here are two standard checks:

  1. Import modpython in shell, from a couple different working directories
  2. Change users (if you have any besides root set up) and repeat step 1

If #2 looks like more trouble than it's worth, then try very, very carefully examining permissions for each folder along the path to modpython to make sure that "other" has read access at every stage along the way. If you've moved django into your home directory (like I did once...not sure why, but got the same error) that'll be the problem. You either need to move it back into a directory where apache can read or you need to add read permission for other.

David Berger
A: 

In my case pytonpath and access rights was ok. This error disappeared after recompilation python.

Configuration:
Gentoo
Django 1.1
Apache:
www-servers/apache-2.2.15 USE="doc ssl suexec threads -debug -ldap (-selinux) -static" APACHE2_MODULES="alias auth_basic authn_alias authn_anon authn_default authn_file authz_default authz_host authz_owner autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias -actions -asis -auth_digest -authn_dbd -authn_dbm -authz_dbm -authz_groupfile -authz_user -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version" APACHE2_MPMS="worker -event -itk -peruser -prefork"
Python 2.6.4

Mintaka