I've had my django app deployed and working perfectly with apache and mod_python, according to the apache deployment instructions. But since I changed the project structure somewhat, I haven't been able to get it working. No matter what I try, I keep getting the following page:
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
Reading various threads, the problem could be one of the following
- incorrect apache configuration file
- incorrect sys.path
- incorrect permissions on any file or directory
- bugs in my django site code
Is there any way to narrow the problem down some? For example, is there a way to find out what sys.path is at the time of error? Are there any log files that can help me here? Is there any way to distinguish between "file not found" and "no permission to read file"? I'd like to approach the solution more scientifically than just trying random things until I stumble upon the solution.
This question is not the same as: Mod_python error: ImportError: Could not import settings. I'm asking specifically for ways to help narrow down the possible solutions, rather than the solutions themselves.