<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Using <code class="notranslate">flask run</code> should result in appropriate import error messages if erroneous imports are used in a flask app.</p>
<p dir="auto">Consider the two flask apps <code class="notranslate">worksjustfine.py</code>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from flask import Flask
app = Flask(__name__)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">flask</span> <span class="pl-k">import</span> <span class="pl-v">Flask</span>
<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Flask</span>(<span class="pl-s1">__name__</span>)</pre></div>
<p dir="auto">and <code class="notranslate">completelymisleading.py</code>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import flask
import batrachomyomachy
app = flask.Flask(__name__)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">flask</span>
<span class="pl-k">import</span> <span class="pl-s1">batrachomyomachy</span>
<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-s1">flask</span>.<span class="pl-v">Flask</span>(<span class="pl-s1">__name__</span>)</pre></div>
<p dir="auto">If you fire up <code class="notranslate">worksjustfine.py</code>, it works just fine:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ FLASK_APP=worksjustfine.py flask run
 * Serving Flask app &quot;worksjustfine&quot;
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)"><pre class="notranslate">$ FLASK_APP=worksjustfine.py flask run
 <span class="pl-k">*</span> Serving Flask app <span class="pl-s"><span class="pl-pds">"</span>worksjustfine<span class="pl-pds">"</span></span>
 <span class="pl-k">*</span> Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)</pre></div>
<p dir="auto">If you fire up <code class="notranslate">completelymisleading.py</code>, you would expect something like this:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ FLASK_APP=completelymisleading.py flask run
...
ImportError: No module named 'batrachomyomachy'"><pre class="notranslate">$ FLASK_APP=completelymisleading.py flask run
...
ImportError: No module named <span class="pl-s"><span class="pl-pds">'</span>batrachomyomachy<span class="pl-pds">'</span></span></pre></div>
<h3 dir="auto">Actual Behavior</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ FLASK_APP=completelymisleading.py flask run
Usage: flask run [OPTIONS]

Error: The file/path provided (completelymisleading) does not appear to exist.  Please verify the path is correct.  If app is not on PYTHONPATH, ensure the extension is .py"><pre class="notranslate">$ FLASK_APP=completelymisleading.py flask run
Usage: flask run [OPTIONS]

Error: The file/path provided (completelymisleading) does not appear to exist.  Please verify the path is correct.  If app is not on PYTHONPATH, ensure the extension is .py</pre></div>
<p dir="auto">This error message is completely misleading, because the file does exist and <code class="notranslate">flask run</code> also starts to import this file. I imagine that somewhere in the <code class="notranslate">flask run</code> code there is a <code class="notranslate">try ... except ImportError</code> that is meant for the situation when the actual flask app can not be found, but one would definitely need a more specific error message for other import errors.</p>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Python version: 3.5.3</li>
<li>Flask version: 0.12</li>
</ul>
<p dir="auto">(Observed on Python 2.7; untested on 3.x)</p>
<h2 dir="auto">Steps to reproduce:</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="echo &quot;import thisisnotarealpackage&quot; &gt; error_app.py
export FLASK_APP=error_app.py
flask run"><pre class="notranslate"><code class="notranslate">echo "import thisisnotarealpackage" &gt; error_app.py
export FLASK_APP=error_app.py
flask run
</code></pre></div>
<h2 dir="auto">Expected result:</h2>
<ul dir="auto">
<li>Some indication that <code class="notranslate">thisisnotarealpackage</code> is not a real package</li>
</ul>
<h2 dir="auto">Observed result:</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Usage: python -m flask run [OPTIONS]

Error: The file/path provided (error) does not appear to exist.
Please verify the path is correct.
If app is not on PYTHONPATH, ensure the extension is .py"><pre class="notranslate"><code class="notranslate">Usage: python -m flask run [OPTIONS]

Error: The file/path provided (error) does not appear to exist.
Please verify the path is correct.
If app is not on PYTHONPATH, ensure the extension is .py
</code></pre></div>
<p dir="auto">(Newlines added)</p>
<h2 dir="auto">Why Bother</h2>
<p dir="auto">This has been causing some confusion on my team because <code class="notranslate">cx_Oracle</code> can fail to import (from the bowels of SQLAlchemy) if it can't find certain Oracle support files on the host machine.</p>