Description
Environment data
- VS Code version: 1.58.2
- Extension version (available under the Extensions sidebar):
- OS and version: MacOS 11.4
- Python version: 3.8.10
- Type of virtual environment used: venv
- Relevant/affected Python packages and their versions: Flask
- Value of the
python.languageServer
setting: "Default"
Expected behaviour
"env" portion of launch.json
doesn't seem to work.
When trying to launch a Flask application I have the following tree structure:
/.venv
/.vscode
/app
-- uwsgi.py ---> Flask Application
My launch.json
file is:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"pythonPath": "${workspaceRoot}/.venv/bin/python",
"env": {
"FLASK_APP": "app/uwsgi.py"
},
"args": ["run"],
"jinja": true
}
]
}
When running the debugger Flask says it can't find application
and the first line shows:
* Serving Flask app "application.py"
So from what I can understand it is as if the env var "FLASK_APP=app/uwsgi.py" is not being read, so it loads the default "application", and can't find the app.
Tried without the debugger and works fine (FLASK_APP=app/uwsgi.py; flask run
).
Another weird thing is that when I set
"env": {
"FLASK_APP": "app/uwsgi.py",
"FLASK_ENV": "development"
},
it goes as for as running the server, but when trying to reach any endpoint it says flask.cli.NoAppException: Could not import "application".
.
If I remove the FLASK_ENV
line it doesn't even run the server and gives me an error: Error: Could not import "application"
.