gunicorn_django -b 0.0.0.0 project_name/settings/production.py
Question: $ python manage.py run_gunicorn 0.0.0.0:80
--settings=project_name.settings.production

<\- It's run, OK.

but, $ gunicorn_django -b 0.0.0.0:80 project_name/settings/production.py

* * *
    
    
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 473, in spawn_worker
        worker.init_process()
      File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 100, in init_process
        self.wsgi = self.app.wsgi()
      File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 106, in wsgi
        self.callable = self.load()
      File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/djangoapp.py", line 102, in load
        return mod.make_wsgi_application()
      File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/django_wsgi.py", line 36, in make_wsgi_application
        if get_validation_errors(s):
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
        for (app_name, error) in get_app_errors().items():
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 166, in get_app_errors
        self._populate()
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 72, in _populate
        self.load_app(app_name, True)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 94, in load_app
        app_module = import_module(app_name)
      File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
        __import__(name)
    > ImportError: No module named accounts
    2013-06-29 01:56:53 [30859] [INFO] Worker exiting (pid: 30859)
    2013-06-29 01:56:53 [30854] [INFO] Shutting down: Master
    2013-06-29 01:56:53 [30854] [INFO] Reason: Worker failed to boot.
    

* * *

How can I solve this problem? I want to run on daemon.

Thanks.


Answer: This looks like an issue related to your `PYTHONPATH`. Try adding the path
that contains the `accounts` module to your python path, using gunicorn's
[`--pythonpath`](http://docs.gunicorn.org/en/latest/configure.html#pythonpath).

If you have newer gunicorn/Django versions using gunicorn via [management
command](http://docs.gunicorn.org/en/latest/run.html#django-manage-py) should
be the preffered way - and it should be more safe regarding issues like this.

