Flask says "did not provide the FLASK_APP environment variable"
<p>I'm trying to run a Flask application with <code>flask run</code> but no matter what, I receive this error:</p>

<pre><code>Error: Could not locate Flask application. You did not provide the FLASK_APP environment variable.
</code></pre>

<p>I'm using virtualenv in my project and I'm running the app on port 80 so I run the command as superuser. Ultimately, I just need to use the <code>flask db init</code> command as described in Flask-Migrate's <a href="https://flask-migrate.readthedocs.io/en/latest/" rel="noreferrer">docs</a>, but <code>flask</code> needs to be able to find the app to do that. Here's what I've tried, with no success:</p>

<p><strong>Exporting the <code>FLASK_APP</code> environment variable, ensuring that it's in my bash profile, then activating virtualenv</strong></p>

<pre><code>$ export FLASK_APP=run.py
$ printenv FLASK_APP
run.py
$ . env/bin/activate
(env) $ sudo flask run
Error: Could not locate Flask application. You did not provide the     FLASK_APP environment variable.
</code></pre>

<p><strong>Activating virtualenv, then exporting <code>FLASK_APP</code></strong></p>

<pre><code>$ . env/bin/activate
(env) $ export FLASK_APP=run.py
(env) $ printenv FLASK_APP
run.py
(env) sudo flask run
Error: Could not locate Flask application. You did not provide the     FLASK_APP environment variable.
</code></pre>

<p><strong>The above two with the full path, <code>/Users/me/code/project/run.py</code></strong></p>

<pre><code>$ printenv FLASK_APP
/Users/me/code/project/run.py
</code></pre>

<p><strong>Project Structure</strong></p>

<pre><code>myproject/
    ├──app/
    |  ├── __init__.py
    |  ├── models.py
    |  ├── templates/
    |  └── views.py
    ├── tests/
    ├── run.py
    ├── requirements.txt
    └── config.py
</code></pre>

<p>So far nothing has worked and the error message is the same in each case. What can I do to fix this error?</p>