2012-04-08 5 views
2

Ich aktualisierte djang1.3.1 zu djang1.4.
In meinem lokalen Umfeld, das ist in Ordnung.
aber wenn ich ci meinen Code zu Server, Fehler passiert ist!
in meinem Server kann ich 'python manage.py shell'
und kann 'Einstellungen importieren', das ist alles in Ordnung,
aber immer noch diesen Fehler, wer kann mir helfen!
ich aktualisiere djang1.3.1 zu djang1.4, error: MOD_PYTHON ERROR

finally, i uninstalled apache , and installed nginx + uwsgi ,fixed this problem.......

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 1229, in _process_target 
result = _execute_target(config, req, object, arg) 

File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target 
result = object(arg) 

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/modpython.py", line 180, in handler 
return ModPythonHandler()(req) 

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/modpython.py", line 142, in __call__ 
self.load_middleware() 

File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 39, in load_middleware 
for middleware_path in settings.MIDDLEWARE_CLASSES: 

File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 184, in inner 
self._setup() 

File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 42, in _setup 
self._wrapped = Settings(settings_module) 

File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 95, in __init__ 
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) 

ImportError: Could not import settings 'guihuame.settings' (Is it on sys.path?): No module named guihuame.settings 

meine Python-Version

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import django 
>>> django.VERSION 
(1, 4, 0, 'final', 0) 

Verwendung manage.py

python manage.py shell 
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
(InteractiveConsole) 
>>> import settings 
Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
ImportError: No module named settings 
>>> import guihuame.settings 
>>> 

thx!

mein Dokumentenbaum ist
guihuame
- manage.py
- guihuame (enthält init Py wsgi.py settings.py urls.py)
- andere Anwendungen

meine wsgi.py, wsgi.py und settings.py sind im selben Ordner

import os 
import sys 
sys.path.insert(0, '/var/web/trunk/guihuame/') 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guihuame.settings") 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 
+0

Sie müssen Ihren PYTHONPATH korrekt einstellen. Zeigen Sie Ihre WSGI-Datei an. – Marcin

+0

Dies ist meine wsgi.py, siehe unten in der Frage – yzliu

+0

Wenn Sie nicht ein weiteres GUIHUAM-Verzeichnis unter ''/ var/web/trunk/guihuame /'' haben, möchten Sie das wahrscheinlich in '/ var/web/ändern trunk/'" – Marcin

Antwort

2

Y ou brauchen eine Linie zu wsgi.py hinzufügen, um den PYTHONPATH den Standort Ihres guihuame Modul hinzufügen:

import sys 
sys.path.insert(0, 'Wherever guihuame is') 

Update: Es liegt an Ihnen, tatsächlich den Standort von guihame bereitzustellen. Führen Sie jedoch keine String-Manipulationen auf Ihren Pfaden durch. Python wählt das richtige Trennzeichen. Wenn ein Problem damit auftritt, verwenden Sie normpath.

Beachten Sie auch, dass os.path.split(os.path.dirname(__file__))[0] entweder Ihre Dateisystemwurzel oder eher eine Ebene darunter auswählt. Dies ist wahrscheinlich nicht das, was Sie wollen.

+0

importieren sys root_path = os.path.split (os.path.dirname (__ file __)) [0] sys.path.insert (0, os.path.join (root_path,' guihuame '). replace ('\\', '/')) es funktioniert nicht ~ – yzliu

+0

@yzliu Was Sie eingefügt haben, ist nicht gültig Python, und es ist nicht der Code, den ich vorgeschlagen habe. Aktualisieren Sie Ihre Antwort mit dem aktuellen Status Ihrer wsgi.py, und ich * kann * Ihnen möglicherweise helfen, wenn Sie auch die Art des Fehlers beschreiben, der bei Ihnen aufgetreten ist. – Marcin

+0

Entschuldigung, ich habe die Frage aktualisiert. siehe unten – yzliu