I’m new to using flask, I tried to execute a basic flask app in Visual-Studio-code . but I’m getting,
No Module named app
My code is:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello, World"
if __name__ == "__main__":
app.run(debug=True)
path :
The output terminal:
PS C:UsersRakeshDesktopThe project copy> c:; cd 'c:UsersRakeshDesktopThe project copy'; & 'C:Python39python.exe' 'c:UsersRakesh.vscodeextensionsms-python.python-2021.5.926500501pythonFileslibpythondebugpylauncher' '52116' '--' 'c:UsersRakeshDesktopThe project copyenvapp.py'
Serving Flask app 'app' (lazy loading)
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
Debug mode: on
Restarting with stat
No module named app
Advertisement
Answer
The path of app.py was inside the virtual environment , thus it is not working. Moving it out of that folder woks.
