title: Gunicorn: Failed to find attribute 'app' in 'wsgi' when attempting to start flask server
body: <p>Gunicorn fails to start flask server with the error: <code>Failed to find attribute 'app' in 'wsgi'.</code>.</p>
  <p>The wsgi.py</p>
  <pre><code>#!/usr/bin/python3
  import sys
  import logging
  logging.basicConfig(stream=sys.stderr)
  sys.path.insert(0,&quot;/root/customer-account-automation/&quot;)
  
  from app import app as application
  if __name__ == &quot;__main__&quot;:
      application.run()
  </code></pre>
  <p>app.py</p>
  <pre><code>#!/usr/bin/python3
  from flask import Flask
  app = Flask(__name__)
  ...
  </code></pre>
  <p>Project structure:</p>
  <pre><code>(customer-account-automation) root@jsd-user-management:~/customer-account-automation# tree
  .
  ├── Pipfile
  ├── Pipfile.lock
  ├── README.md
  ├── __pycache__
  │   ├── app.cpython-37.pyc
  │   └── wsgi.cpython-37.pyc
  ├── app.py
  ├── customerAccountMgmt.py
  ├── get-pip.py
  ├── static
  │   ├── app.js
  │   ├── bulma.min.css
  │   ├── highlight.min.css
  │   ├── highlight.min.js
  │   └── styles.css
  ├── templates
  │   ├── 404.html
  │   ├── base.html
  │   ├── change_password.html
  │   ├── create_user.html
  │   ├── deactivate_user.html
  │   └── login.html
  └── wsgi.py
  </code></pre>
  <p>I checked (<a href="https://stackoverflow.com/questions/33379287/gunicorn-cant-find-app-when-name-changed-from-application/33379650">Gunicorn can&#39;t find app when name changed from &quot;application&quot;</a>) but it doesn't relate to mine as I already use the <code>application</code>.</p>
  <p>Any ideas what could be the problem?</p>