I know several similar questions have been posted, but none of their solution works for me. Could you help figure out how to resolve this issue? Any help is appreciated.
version info:
apache2 2.4.7
os Ubuntu 14.04
django 1.8
Error message
MOD_PYTHON ERROR
ProcessId: 15796
Interpreter: '127.0.1.1'
ServerName: '127.0.1.1'
DocumentRoot: '/var/www/html'
URI: '/'
Location: None
Directory: None
Filename: '/home/stevenhe/mywork/src/listbaby/listbaby/wsgi.py'
PathInfo: '/'
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.7/dist-packages/mod_python/publisher.py", line 204, in handler
module = page_cache[req]
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1059, in __getitem__
return import_module(req.filename)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 296, in import_module
log, import_path)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 680, in import_module
execfile(file, module.__dict__)
File "/home/stevenhe/mywork/src/listbaby/listbaby/wsgi.py", line 18, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named listbaby.settings
My Project structure :
project path: /home/stevenhe/mywork/src/listbaby
app name: listbaby
abs path to wsgi.py = /home/stevenhe/mywork/src/listbaby/lisbaby/wsgi.py
abs path to settings.py = /home/stevenhe/mywork/src/listbaby/lisbaby/settings.py
content of wsgi.py
import os, sys
from django.core.wsgi import get_wsgi_application
#sys.path.append('/home/stevenhe/mywork/src/listbaby') if I add this line, http simply returns 404 error
sys.path.append('/home/stevenhe/mywork/src/listbaby/listbaby')
os.environ["DJANGO_SETTINGS_MODULE"]="listbaby.settings"
application = get_wsgi_application()
content of apache2.conf
WSGIScriptAlias / /home/stevenhe/mywork/src/listbaby/listbaby/wsgi.py
WSGIPythonPath /home/stevenhe/mywork/src/listbaby
<Directory /home/stevenhe/mywork/src/listbaby/listbaby>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
You're missing a package to install that is listed in INSTALLED_APPS. This was a regression - if you upgrade to the latest Django 1.8.x, it will tell you the missing app. Install it via pip and you should be good.
确保项目内的manage.py文件的os.environ设置为listbaby.settings。
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "listbaby.settings")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.