I built a flask project application in visual studio code, including a very simple flask application:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Hello world!"
there is a venv
virtual environment under the project folder. Under powershell, start the virtual environment to run the flask program normally. But when I added the python interpreter path corresponding to the virtual environment under the project folder to the workspace settings of visual studio code, visual studio reported an error, and the error reported was a bit strange:
Error: Could not import "D".
the python paths I added in the workspace settings are as follows. I have tried both and reported the above errors:
{
"python.pythonPath": "${workspaceFolder}/venv/Scripts/python.exe",
//"python.pythonPath": "D:/_TEMP/venv/Scripts/python.exe",
}
deleting the added python path, visual studio code in the workspace configuration will run the program properly. (because I installed the flask framework under the global path)
question: how do I configure the python path for the virtual environment in visual studio code?