views:

148

answers:

3

Hi,

I tried to install django on my apache on mod_wsgi ,

I have this error : ImportError: No module named django.core.handlers.wsgi,

I v read, may be it's some user problem...

On console ssh, with root access no problem to access django.core.handlers.wsgi , but when apache ask to access it doesn't work... i need help Thx

My django.wsgi

import os
import sys

sys.path.append('my/rep/parents/of/my/projet')
sys.path.append('/usr/lib/python2.4/site-packages/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'montest.settings'
os.environ['PYTHON_EGG_CACHE'] = '/tmp'


import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

My vhost.conf

Alias /media/ my/rep/parents/of/my/projet/montest/media/

<Directory my/rep/parents/of/my/projet/montest/media>
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias /montest my/rep/parents/of/my/projet/django.wsgi

<Directory my/rep/parents/of/my/projet>
Order deny,allow
Allow from all
</Directory>

My error :

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

EDIT :

Ok my result for ldd mod_wsgi.so

linux-gate.so.1 => (0x0013c000) 
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00663000) 
libpthread.so.0 => /lib/libpthread.so.0 (0x00bff000) 
libdl.so.2 => /lib/libdl.so.2 (0x0023b000) 
libutil.so.1 => /lib/libutil.so.1 (0x00420000) 
libm.so.6 => /lib/libm.so.6 (0x00110000) 
libc.so.6 => /lib/libc.so.6 (0x00240000) /lib/ld-linux.so.2 (0x0059f000) 

So i decide to test my mod_wsgi install with the test.wsgi

test.wsgi

    def application(environ, start_response): 
status = '200 OK' output = 'Hello world, I am a wsgi app!' 
response_headers = [('Content-Type', 'text/plain'), ('Content-Length',   str(len(output)))] 
start_response(status, response_headers) 
return [output]

my vhost.conf

WSGIScriptAlias /test /var/www/vhosts/mydomain.fr/subdomains/django/httpdocs/test.wsgi 
<Directory /var/www/vhosts/mydomain.fr/subdomains/django/httpdocs> 
Order allow,deny 
Allow from all 
Options +ExecCGI 
</Directory> 

It's work... i tries now with my django config

A: 

This line is certainly wrong:

sys.path.append('/usr/lib/python2.4/site-packages/django')

Install Django with/for the version of Python that mod_wsgi was built against.

Ignacio Vazquez-Abrams
i v read : "And Python 2.X version from Python 2.3 onwards can be used"http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide
laurent
That's nice. Did you read my answer?
Ignacio Vazquez-Abrams
yes... you say i need to install mod_wsgi for python2.4 if i used python2.4 with my django ? correct ?
laurent
Or you need to install Django for whatever version of Python that mod_wsgi is for.
Ignacio Vazquez-Abrams
A: 

I've had this issue before, and it was because the Apache/mod_wsgi process did not have permission to read the modules. You can make your site-packages/django directory world-readable, or add other appropriate user/group permissions.

Bob
i v tried, doesn't work anymore
laurent
+1  A: 

Why are you even trying to add the site-packages directory into sys.path? If your mod_wsgi is compiled against Python 2.4, then it should already be looking in the site-packages directory. Sounds like your mod_wsgi isn't even compiled against Python 2.4.

Run:

ldd mod_wsgi.so

against your installed mod_wsgi.so file to work out what Python version it is compiled for and post the result.

Graham Dumpleton