生产服务器没有从venv导入东西?

时间:2016-01-29 06:05:30

标签: python django

在我的生产服务器中,我正在尝试导入我的venv apps目录中的另一个设置文件,而不是导入导致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>
    from spirit.settings import *
ImportError: No module named spirit.settings

但模块显然在那里,当我启动我的生产服务器venv python解释器并尝试导入它时,它就好了

EIDT添加GUNICORN START SCRIPT?:

description "Gunicorn daemon for Django project"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]

# If the process quits unexpectadly trigger a 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

1 个答案:

答案 0 :(得分:1)

无法找到项目的django设置。

编辑:

最可能的问题是,您没有在gunicorn命令中将正确的路径传递给项目。根据项目的目录结构,它无法找到该项目的设置文件。在您共享您正在使用的gunicorn命令之前,我无法验证这一点,这会产生您在问题中分享的错误。