Gunicorn failed to load Flask application
<p>I have a Flask app I am trying to serve via Gunicorn.</p>

<p>I am using virtualenv and python3. If I activate my venv cd to my app base dir then run:</p>

<pre><code>gunicorn mysite:app
</code></pre>

<p>I get:</p>

<pre><code>Starting gunicorn
Listening at http://127.0.0.1:8000
DEBUG:mysite.settings:&gt;&gt;Config()
...
Failed to find application: 'mysite'
Worker exiting
Shutting down: master
Reason: App failed to load
</code></pre>

<p>Looking in /etc/nginx/sites-available I only have the file 'default'. In sites-enabled I have no file.</p>

<p>In my nginx.conf file I have:</p>

<pre><code>include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
</code></pre>

<p>App structure:</p>

<pre><code>mysite    #this is where I cd to and run gunicorn mysite:app
--manage.py
--/mysite
----settings.py
----__init__.py
</code></pre>

<p>in <code>manage.py</code> for mysite I have following:</p>

<pre><code>logger.debug("manage.py entry point")
app = create_app(app_name)
manager = Manager(app)

if __name__ == "__main__":
    manager.run()
</code></pre>

<p>In <code>__init__.py</code> file:</p>

<pre><code>def create_app(object_name):
    app = Flask(__name__)
    #more setup here
    return app
</code></pre>

<p>In my <code>settings.py</code> in the app directory</p>

<pre><code>class Config(object):
    logger.debug("&gt;&gt;Config()")  #this logs OK so gunicorn is at least starting in correct directory
</code></pre>

<p>From inside the virtualenv if I run </p>

<pre><code>print(sys.path)
</code></pre>

<p>I find a path to python and site-packages for this virtualenv.</p>

<p>From what I have read to start gunicorn it's just a matter of installing it and running gunicorn mysite:app</p>

<p>Running gunicorn from the parent directory of mysite I get the same failed to find application: 'mysite', App failed to load error, but don't get the DEBUG...Config() logged (as we are clearly in the wrong directory to start in). Running gunicorn from mysite/mysite (clearly wrong) I get and Exception in worker process ereor, ImportError: No module named 'mysite'.</p>

<p>Any clues as to how I can get gunicorn running?</p>