title: Flask Tutorial: Could Not Import app in Visual Studio Code 1.37.1
body: <p>Am trying to learn Python3 / Flask using Visual Studio Code on my macOS machine.</p>
  
  <p>Using:</p>
  
  <ul>
  <li>macOS Mojave (10.14.6)</li>
  <li>Visual Studio Code 1.37.1</li>
  <li>Python 3.7.4 64 bit (venv)</li>
  </ul>
  
  <p>Tried the instructions in the following tutorial:</p>
  
  <p><a href="https://code.visualstudio.com/docs/python/tutorial-flask" rel="nofollow noreferrer">https://code.visualstudio.com/docs/python/tutorial-flask</a></p>
  
  <ol>
  <li>Created a virtual env by inside the newly created hello_flask folder:</li>
  </ol>
  
  <pre><code>   python3 -m venv venv
  </code></pre>
  
  <ol start="2">
  <li>Opened the project folder in VS Code by running:</li>
  </ol>
  
  <pre><code>   code .
  </code></pre>
  
  <ol start="3">
  <li>Opened the Command Palette (Shift-Cmd-P) and typed / selected:</li>
  </ol>
  
  <pre><code>Python:Select Interpreter
  </code></pre>
  
  <ol start="4">
  <li>Picked Python 3.7.4 64-bit ('venv':venv)</li>
  <li>Opened the Command Palette (Shift-Cmd-P) and typed / selected:</li>
  </ol>
  
  <pre><code>Terminal: Create New Integrated Terminal
  </code></pre>
  
  <ol start="6">
  <li>Installed Flask via the VS Code Terminal using the following command:</li>
  </ol>
  
  <pre><code>pip3 install flask
  </code></pre>
  
  <ol start="7">
  <li>Created a new file called app.py and entered in the following source code:</li>
  </ol>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  @app.route("/")
  def home():
      return "Hello, Flask!"
  </code></pre>
  
  <ol start="8">
  <li>When trying to run it inside VS Code's terminal:</li>
  </ol>
  
  <pre><code>(venv) user1@devbox:~/hello_flask$ python3 flask run
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'flask': [Errno 2] No such file or directory
  (venv) user1@devbox:~/hello_flask$
  </code></pre>
  
  <ol start="9">
  <li>When trying this instead:</li>
  </ol>
  
  <pre><code>(venv) user1@devbox:~/hello_flask$ flask run
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code> * Serving Flask app "app.py"
   * Environment: production
     WARNING: This is a development server. Do not use it in a production deployment.
     Use a production WSGI server instead.
   * Debug mode: off
  Usage: flask run [OPTIONS]
  
  Error: Could not import "app".
  </code></pre>
  
  <ol start="10">
  <li>Even tried this:</li>
  </ol>
  
  <pre><code>export FLASK_APP=app.py
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code> * Serving Flask app "app.py"
   * Environment: production
     WARNING: This is a development server. Do not use it in a production deployment.
     Use a production WSGI server instead.
   * Debug mode: off
  Usage: flask run [OPTIONS]
  
  Error: Could not import "app".
  </code></pre>
  
  <p>What am I possibly doing wrong? </p>
  
  <p>Is there something wrong with the official documentation hosted by</p>
  
  <p>Microsoft &lt; <a href="https://code.visualstudio.com/docs/python/tutorial-flask" rel="nofollow noreferrer">https://code.visualstudio.com/docs/python/tutorial-flask</a>> ?</p>