title: Why can't FLASK_APP find my factory function?
body: <p>I am trying to reconfigure an existing Flask app with an application factory to be installed with <code>setup.py</code>.</p>
  
  <p>Currently, with my non-installable package, I use a file called <code>wsgi.py</code> and point <code>FLASK_APP</code> at that.</p>
  
  <pre><code>from example.factory import create_app
  app = create_app()
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>export FLASK_APP=wsgi.py
  flask run
  </code></pre>
  
  <p>However, if I try to point Flask directly at the factory in the installed package, I get<code>RuntimeError: Failed to find application in module "example.factory"</code>. I found this pattern in the <a href="https://github.com/pallets/flask/tree/master/examples/flaskr" rel="nofollow noreferrer">examples in the Flask repository</a>.</p>
  
  <pre><code>export FLASK_APP="example.factory:create_app()"
  flask run  # doesn't find the app
  </code></pre>
  
  <p>Why does the <code>wsgi.py</code> method work while the direct method fails?</p>