根據apache的部署說明,我已經部署了我的django應用並且能夠完美地使用apache和mod_python。但是由於我在某種程度上改變了項目結構,所以我一直無法得到它的工作。不管我怎麼努力,我不斷收到以下頁面:如何排除故障 - 導入錯誤:部署django時無法導入設置'mysite.settings'?
MOD_PYTHON ERROR
ProcessId: 27841
Interpreter: '127.0.0.1'
ServerName: '127.0.0.1'
DocumentRoot: '/var/www'
URI: '/myapp/'
Location: '/myapp/'
Directory: None
Filename: '/var/www/myapp'
PathInfo: '/'
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
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-1.3.1-py2.6.egg/django/core/handlers/modpython.py", line 212, in handler
return ModPythonHandler()(req)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3.1-py2.6.egg/django/core/handlers/modpython.py", line 174, in __call__
self.load_middleware()
File "/usr/local/lib/python2.6/dist-packages/Django-1.3.1-py2.6.egg/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-1.3.1-py2.6.egg/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/local/lib/python2.6/dist-packages/Django-1.3.1-py2.6.egg/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.6/dist-packages/Django-1.3.1-py2.6.egg/django/conf/__init__.py", line 89, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings
閱讀不同的線程,這個問題可能是由以下
- 不正確的Apache配置文件
- 不正確的sys.path 之一
- 上的任何文件或目錄
- 蟲子在我的Django的網站代碼不正確的權限
有什麼辦法可以縮小問題的範圍嗎?例如,有沒有辦法找出錯誤發生時的sys.path?有沒有可以幫助我的日誌文件?有沒有辦法區分「找不到文件」和「沒有讀文件的權限」?我希望更科學地解決這個解決方案,而不是僅僅嘗試隨機的東西,直到我偶然發現解決方案。
這個問題不是一樣的:Mod_python error: ImportError: Could not import settings。我特意要求幫助縮小可能的解決方案的方法,而不是解決方案本身。
你是使用virtualenv還是隻使用全局python?你也可以發佈你的.wsgi conf文件嗎?這是設置模塊導入的地方,可能是問題出在 –
發佈項目文件樹的表示。 –
我確實在尋找一般的故障排除提示,而不是解決我的問題。給一個男人一條魚... – amarillion