我更新了djang1.3.1到djang1.4。
在我的本地環境中,沒關係。
但是當我ci我的代碼到服務器,發生錯誤!
在我的服務器上,我可以使用'python manage.py shell'
並且可以'導入設置',沒關係,
但是仍然有這個錯誤,誰能幫幫我!
我更新djang1.3.1到djang1.4,錯誤:MOD_PYTHON錯誤
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
我的Python版本
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)
使用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!
我的文檔樹是
guihuame
- manage.py
- guihuame(包含初始化的.py wsgi.py settings.py urls.py)
- 其他應用
我wsgi.py,wsgi.py和settings.py是在同一文件夾
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()
您需要正確設置您的PYTHONPATH。顯示你的WSGI文件。 – Marcin 2012-04-08 12:32:30
這是我的wsgi.py,看問題底部 – yzliu 2012-04-08 12:38:25
除非你在'/ var/web/trunk/guihuame /'目錄下還有一個guihuame目錄,否則你可能想把它改成''/ var/web/' – Marcin 2012-04-08 14:12:58