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:
JavaScript
x
12
12
1
from flask import Flask
2
app = Flask(__name__)
3
4
5
@app.route('/')
6
def index():
7
return "Hello, World"
8
9
10
if __name__ == "__main__":
11
app.run(debug=True)
12
path :
The output terminal:
JavaScript
1
10
10
1
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'
2
3
Serving Flask app 'app' (lazy loading)
4
Environment: production
5
WARNING: This is a development server. Do not use it in a production deployment.
6
Use a production WSGI server instead.
7
Debug mode: on
8
Restarting with stat
9
No module named app
10
Advertisement
Answer
The path of app.py was inside the virtual environment , thus it is not working. Moving it out of that folder woks.