title: How I fix erro in gunicorn when I deploy django app in Heroku?
body: <p>When I run <code>git push heroku master</code>the build works with success, but, the app doen't works... Looking for some problems I open logs <code>heroku logs</code>and have it:</p>
  
  <pre><code>&gt; heroku logs
  2016-11-17T16:53:48.005794+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
  2016-11-17T16:53:48.005794+00:00 app[web.1]:     return util.import_app(self.app_uri)
  2016-11-17T16:53:48.005794+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
  2016-11-17T16:53:48.005795+00:00 app[web.1]:     __import__(module)
  2016-11-17T16:53:48.005795+00:00 app[web.1]:   File "/app/myapp/wsgi.py", line 22, in &lt;module&gt;
  2016-11-17T16:53:48.005796+00:00 app[web.1]:     application = get_wsgi_application()
  2016-11-17T16:53:48.005796+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
  2016-11-17T16:53:48.005797+00:00 app[web.1]:     django.setup()
  2016-11-17T16:53:48.005797+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
  2016-11-17T16:53:48.005798+00:00 app[web.1]:     apps.populate(settings.INSTALLED_APPS)
  2016-11-17T16:53:48.005798+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
  2016-11-17T16:53:48.005798+00:00 app[web.1]:     app_config = AppConfig.create(entry)
  2016-11-17T16:53:48.005799+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/apps/config.py", line 90, in create
  2016-11-17T16:53:48.005799+00:00 app[web.1]:     module = import_module(entry)
  2016-11-17T16:53:48.005800+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/importlib/__init__.py", line 126, in import_module
  2016-11-17T16:53:48.005800+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
  2016-11-17T16:53:48.005803+00:00 app[web.1]: ImportError: No module named 'base'
  2016-11-17T16:53:48.006060+00:00 app[web.1]: [2016-11-17 13:53:48 -0300] [8] [INFO] Worker exiting (pid: 8)
  2016-11-17T16:53:48.121161+00:00 app[web.1]: [2016-11-17 13:53:48 -0300] [9] [ERROR] Exception in worker process
  2016-11-17T16:53:48.121165+00:00 app[web.1]: Traceback (most recent call last):
  2016-11-17T16:53:48.121166+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
  2016-11-17T16:53:48.121167+00:00 app[web.1]:     worker.init_process()
  2016-11-17T16:53:48.121168+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
  2016-11-17T16:53:48.121169+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
  2016-11-17T16:53:48.121168+00:00 app[web.1]:     self.load_wsgi()
  2016-11-17T16:53:48.121176+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
  2016-11-17T16:53:48.121177+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
  2016-11-17T16:53:48.121189+00:00 app[web.1]:     self.callable = self.load()
  2016-11-17T16:53:48.121190+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
  2016-11-17T16:53:48.121191+00:00 app[web.1]:     return self.load_wsgiapp()
  2016-11-17T16:53:48.121192+00:00 app[web.1]:     return util.import_app(self.app_uri)
  2016-11-17T16:53:48.121192+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
  2016-11-17T16:53:48.121193+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
  2016-11-17T16:53:48.121193+00:00 app[web.1]:     __import__(module)
  2016-11-17T16:53:48.121194+00:00 app[web.1]:   File "/app/myapp/wsgi.py", line 22, in &lt;module&gt;
  2016-11-17T16:53:48.121195+00:00 app[web.1]:     application = get_wsgi_application()
  2016-11-17T16:53:48.121196+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
  2016-11-17T16:53:48.121196+00:00 app[web.1]:     django.setup()
  2016-11-17T16:53:48.121197+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
  2016-11-17T16:53:48.121198+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
  2016-11-17T16:53:48.121197+00:00 app[web.1]:     apps.populate(settings.INSTALLED_APPS)
  2016-11-17T16:53:48.121199+00:00 app[web.1]:     app_config = AppConfig.create(entry)
  2016-11-17T16:53:48.121200+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/apps/config.py", line 90, in create
  2016-11-17T16:53:48.121200+00:00 app[web.1]:     module = import_module(entry)
  2016-11-17T16:53:48.121201+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/importlib/__init__.py", line 126, in import_module
  2016-11-17T16:53:48.121201+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
  2016-11-17T16:53:48.121207+00:00 app[web.1]: ImportError: No module named 'base'
  2016-11-17T16:53:48.121584+00:00 app[web.1]: [2016-11-17 13:53:48 -0300] [9] [INFO] Worker exiting (pid: 9)
  2016-11-17T16:53:48.192257+00:00 app[web.1]: Traceback (most recent call last):
  2016-11-17T16:53:48.192263+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 196, in run
  2016-11-17T16:53:48.192604+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 346, in sleep
  2016-11-17T16:53:48.192600+00:00 app[web.1]:     self.sleep()
  2016-11-17T16:53:48.192790+00:00 app[web.1]:     ready = select.select([self.PIPE[0]], [], [], 1.0)
  2016-11-17T16:53:48.192792+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 231, in handle_chld
  2016-11-17T16:53:48.192947+00:00 app[web.1]:     self.reap_workers()
  2016-11-17T16:53:48.192950+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 506, in reap_workers
  2016-11-17T16:53:48.193196+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
  2016-11-17T16:53:48.193244+00:00 app[web.1]: gunicorn.errors.HaltServer: &lt;HaltServer 'Worker failed to boot.' 3&gt;
  2016-11-17T16:53:48.193247+00:00 app[web.1]:
  2016-11-17T16:53:48.193248+00:00 app[web.1]: During handling of the above exception, another exception occurred:
  2016-11-17T16:53:48.193249+00:00 app[web.1]:
  2016-11-17T16:53:48.193251+00:00 app[web.1]: Traceback (most recent call last):
  2016-11-17T16:53:48.193273+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in &lt;module&gt;
  2016-11-17T16:53:48.193397+00:00 app[web.1]:     sys.exit(run())
  2016-11-17T16:53:48.193401+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
  2016-11-17T16:53:48.193540+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  2016-11-17T16:53:48.193544+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py", line 192, in run
  2016-11-17T16:53:48.193706+00:00 app[web.1]:     super(Application, self).run()
  2016-11-17T16:53:48.193710+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/app/base.py", line 72, in run
  2016-11-17T16:53:48.193831+00:00 app[web.1]:     Arbiter(self).run()
  2016-11-17T16:53:48.194037+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 331, in halt
  2016-11-17T16:53:48.194003+00:00 app[web.1]:     self.halt(reason=inst.reason, exit_status=inst.exit_status)
  2016-11-17T16:53:48.193848+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 218, in run
  2016-11-17T16:53:48.194242+00:00 app[web.1]:     self.stop()
  2016-11-17T16:53:48.194266+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 381, in stop
  2016-11-17T16:53:48.194442+00:00 app[web.1]:     time.sleep(0.1)
  2016-11-17T16:53:48.194446+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 231, in handle_chld
  2016-11-17T16:53:48.194594+00:00 app[web.1]:     self.reap_workers()
  2016-11-17T16:53:48.194598+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/gunicorn/arbiter.py", line 506, in reap_workers
  2016-11-17T16:53:48.194811+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
  2016-11-17T16:53:48.194841+00:00 app[web.1]: gunicorn.errors.HaltServer: &lt;HaltServer 'Worker failed to boot.' 3&gt;
  2016-11-17T19:16:42.778427+00:00 heroku[slug-compiler]: Slug compilation started
  2016-11-17T19:16:42.778433+00:00 heroku[slug-compiler]: Slug compilation finished
  2016-11-17T19:16:42.979828+00:00 heroku[web.1]: State changed from crashed to starting
  2016-11-17T19:16:50.202921+00:00 heroku[web.1]: Starting process with command `gunicorn myapp.wsgi --log-file -`
  2016-11-17T19:16:52.256740+00:00 heroku[web.1]: Process exited with status 127
  2016-11-17T19:16:52.245591+00:00 heroku[web.1]: State changed from starting to crashed
  2016-11-17T19:16:52.246568+00:00 heroku[web.1]: State changed from crashed to starting
  2016-11-17T19:16:52.170203+00:00 app[web.1]: bash: gunicorn: command not found
  2016-11-17T19:17:00.048099+00:00 heroku[web.1]: Starting process with command `gunicorn myapp.wsgi --log-file -`
  2016-11-17T19:17:02.005321+00:00 heroku[web.1]: Process exited with status 127
  2016-11-17T19:17:02.025530+00:00 heroku[web.1]: State changed from starting to crashed
  2016-11-17T19:17:01.929591+00:00 app[web.1]: bash: gunicorn: command not found
  2016-11-17T19:17:02.796563+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=5a35818e-0f8d-4343-9b86-18b07bd14f59 fwd="186.249.59.170" dyno= connect= service= status=503 bytes=
  2016-11-17T19:17:15.898320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=1354b49b-b9c9-48a1-9917-5d4b5241fdda fwd="186.249.59.170" dyno= connect= service= status=503 bytes=
  2016-11-17T19:18:06.649990+00:00 heroku[run.2110]: Awaiting client
  2016-11-17T19:18:06.673878+00:00 heroku[run.2110]: Starting process with command `bash`
  2016-11-17T19:18:06.905693+00:00 heroku[run.2110]: State changed from starting to up
  2016-11-17T19:19:37.129610+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=5922ceca-9f79-46c0-8b05-3fdc86989081 fwd="186.249.59.170" dyno= connect= service= status=503 bytes=
  2016-11-17T19:20:00.589411+00:00 heroku[run.2110]: Process exited with status 148
  2016-11-17T19:20:00.600754+00:00 heroku[run.2110]: State changed from up to complete
  </code></pre>
  
  <p>My Procfile is standard <code>web: gunicorn opportunis.wsgi --log-file -</code> and my settings is:</p>
  
  <pre><code>settings
  |_ __init__.py
  |_ locals_settings.py
  |_ sever_settings.py
  </code></pre>
  
  <p>In <code>__init__.py</code> I have it:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import os
  
  var = os.getenv('IS_SERVER', 0)
  
  if bool(var):
      try:
          from .server_settings import *
      except ImportError:
          from .locals_settings import *
  </code></pre>
  
  <p>And the diference between <code>locals_settings</code>and <code>server_settings</code>is <code>debug off</code>, <code>DATABASES</code>and some configs to <code>dj_database_url</code>. In <code>wsgi.py</code>I have this code:</p>
  
  <pre><code>import os
  var = os.getenv('IS_SERVER', 0)
  
  from django.core.wsgi import get_wsgi_application
  from whitenoise.django import DjangoWhiteNoise
  
  if bool(var):
      try:
          os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings.server_settings")
      except ImportError:
          os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings.locals_settings")
  
  application = get_wsgi_application()
  application = DjangoWhiteNoise(application)
  </code></pre>
  
  <p>What I did or didn't to failed?</p>