python - production server not importing stuff from venv? -


in production server trying import settings file in venv apps directory , not importing causing 502...

traceback (most recent call last):   file "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 473, in spawn_worker     worker.init_process()   file "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 100, in init_process     self.wsgi = self.app.wsgi()   file "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 115, in wsgi     self.callable = self.load()   file "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 33, in load     return util.import_app(self.app_uri)   file "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 362, in import_app     __import__(module)   file "/home/django/langalang/langalang/wsgi.py", line 15, 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)   file "/home/django/langalang/langalang/settings.py", line 16, in <module>     spirit.settings import * importerror: no module named spirit.settings 

but module there , when start production servers venv python interpreter , try import it, goes fine

eidt adding gunicorn start script?:

description "gunicorn daemon django project"  start on (local-filesystems , net-device-up iface=eth0) stop on runlevel [!12345]  # if process quits unexpectadly trigger respawn respawn  setuid django setgid django chdir /home/django  exec gunicorn \     --name=project \     --pythonpath=project \     --bind=0.0.0.0:9000 \     --config /etc/gunicorn.d/gunicorn.py \     project.wsgi:application 

it's unable find django settings project.

edit:

the issue, aren't passing right path project in gunicorn command. depending on project's directory structure it's unable find settings file project. i'm unable verify until you've shared gunicorn command you're using, produces error shared in question.


Comments