VSCode does not recognize my Flask dependency installed with Poetry
Question:
I am learning how to use VSCode for Python development by building a simple Flask app. I use Poetry for dependency management.
I have a simple app.py
where I’m importing flask
and defining a basic route like so:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
return "Hello, Flask!"
In the VSCode terminal, I run poetry shell
and then python -m flask run
, and the server starts up no problem. I’m able to hit the endpoint and get a response.
However, my VSCode editor is telling me that it’s unable to import flask
. I’m unable to run the VSCode debugger for this reason.
I’m missing some step. Does anybody have any idea? Thank you in advance!
Answers:
Re-starting VSCode did the trick. I wasn’t seeing the Poetry interpreter when I looked for it via cmd+shift+p
and Python: Select Interpreter
prior to re-starting, and now I do. Selecting the Poetry interpreter it fixes the issue!
I am learning how to use VSCode for Python development by building a simple Flask app. I use Poetry for dependency management.
I have a simple app.py
where I’m importing flask
and defining a basic route like so:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
return "Hello, Flask!"
In the VSCode terminal, I run poetry shell
and then python -m flask run
, and the server starts up no problem. I’m able to hit the endpoint and get a response.
However, my VSCode editor is telling me that it’s unable to import flask
. I’m unable to run the VSCode debugger for this reason.
I’m missing some step. Does anybody have any idea? Thank you in advance!
Re-starting VSCode did the trick. I wasn’t seeing the Poetry interpreter when I looked for it via cmd+shift+p
and Python: Select Interpreter
prior to re-starting, and now I do. Selecting the Poetry interpreter it fixes the issue!