2011-06-23 2 views
2

J'essaie de configurer apache, mod_wsgi et django. Je reçois une erreur de serveur interne dans mon erreur apache journal:Aucun module nommé os trouvé - Django, mod_wsgi, Apache 2.2

[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-development.wsgi' cannot be loaded as Python module. 
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Exception occurred processing WSGI script '/django/internal/django-development.wsgi'. 
[Wed Jun 22 21:31:55 2011] [error] Traceback (most recent call last): 
[Wed Jun 22 21:31:55 2011] [error] File "/django/internal/django-development.wsgi", line 3, in <module> 
[Wed Jun 22 21:31:55 2011] [error]  import sys, os 
[Wed Jun 22 21:31:55 2011] [error] ImportError: No module named os 
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-development.wsgi' cannot be loaded as Python module. 
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Exception occurred processing WSGI script '/django/internal/django-development.wsgi'. 
[Wed Jun 22 21:31:55 2011] [error] Traceback (most recent call last): 
[Wed Jun 22 21:31:55 2011] [error] File "/django/internal/django-development.wsgi", line 3, in <module> 
[Wed Jun 22 21:31:55 2011] [error]  import sys, os 
[Wed Jun 22 21:31:55 2011] [error] ImportError: No module named os 

django-development.wsgi

#! /usr/bin/env python 

import sys, os 

path = '/django/internal' 
if path not in sys.path: 
    sys.path.append(path) 

os.environ['DJANGO_SETTINGS_MODULE'] = 'internal.settings' 

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

S'il vous plaît laissez-moi savoir s'il y a quelque chose (fichiers de configuration, par exemple) I peut poster pour vous aider à diagnostiquer ce problème.

modifier:

c'est étrange, étant donné que je pensais que je mets ma version python par défaut à 2,5 .., et couru ./configure avec le python2.5 comme paramètre

$otool -L mod_wsgi.somod_wsgi.so: 
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10) 
    /System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1) 

et

LoadModule wsgi_module libexec/apache2/mod_wsgi.so 
WSGIScriptAlias//django/internal/django-development.wsgi 

modifier:

Ah, on dirait qu'un mauvais fichier de configuration a été importé. Je l'ai maintenant pour me donner la sortie suivante. Progrès:

[Wed Jun 22 23:04:28 2011] [error] Exception ImportError: 'No module named atexit' in 'garbage collection' ignored 
Fatal Python error: unexpected exception during garbage collection 
[Wed Jun 22 23:04:28 2011] [error] Exception ImportError: 'No module named atexit' in 'garbage collection' ignored 
Fatal Python error: unexpected exception during garbage collection 
[Wed Jun 22 23:04:29 2011] [notice] caught SIGTERM, shutting down 
[Wed Jun 22 23:04:29 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] 
[Wed Jun 22 23:04:29 2011] [warn] mod_wsgi: Compiled for Python/2.5.4. 
[Wed Jun 22 23:04:29 2011] [warn] mod_wsgi: Runtime using Python/2.6.1. 
[Wed Jun 22 23:04:29 2011] [notice] Digest: generating secret for digest authentication ... 
[Wed Jun 22 23:04:29 2011] [notice] Digest: done 
[Wed Jun 22 23:04:29 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations 
[Wed Jun 22 23:06:04 2011] [error] [client ::1] client denied by server configuration: /django/internal/django-development.wsgi 

modifier

Alors, je voudrais encore savoir comment faire python run mod_wsgi 2,5 au lieu de 2,6 - c'est ce qui me cause de mes grandes questions en ce moment. Au-delà de cela, il devrait juste être peaufiner la configuration d'apache.

+0

Quelle version de python? Pouvez-vous 'importer os' d'un interpréteur python normal? –

+0

Version 2.5 - et oui, je peux. –

+0

Pouvez-vous inclure une liste de fichiers qui se trouvent dans le même répertoire que 'django-development.wsgi'? –

Répondre

1

Pour une raison quelconque, mod_wsgi ne peut pas voir votre bibliothèque Py2.5. Je suggère de vérifier la valeur de WSGIPythonPath et assurez-vous qu'il pointe vers quelque chose comme /usr/lib/python2.5

+0

Je mets 'WSGIPythonPath/System/Bibliothèque/Frameworks/Python.framework/Versions/2.5/bin/python2.5' dans httpd.conf, redémarre apache, mais toujours le même résultat (et la même sortie que précédemment avec la commande otool) . –

+0

pour être clair: WSGIPythonPath n'est pas le chemin vers le binaire python, c'est un chemin de recherche vers le répertoire des modules python. le premier répertoire de la liste séparée ':' devrait être le répertoire qui contient os.py. allez [ici] (http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath) pour plus d'informations. – Thomas

+0

Ok, merci pour avoir clarifié - Je l'ai modifié pour inclure /usr/lib/python2.5 (et j'ai vérifié pour m'assurer que c'était correct), pourtant il sent toujours le besoin de courir avec 2.6 pour une raison quelconque. –

Questions connexes