I've been trying to get the debugger working in VS Code so that I can debug my Flask App. I have tries so many options in the launch.json that I feel there isn't any left.
the following examples did not work: https://github.com/DonJayamanne/pythonVSCode/wiki/Debugging:-Flask
Debug Flask(Python) web application in Visual studio code
Below are my launch.json and setting.json. I have two configurations in the launch file as I was trying multiple variations.
launch.json
"version": "0.2.0",
"configurations": [
{
"name": "Flask",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
//"module": "flask.cli",
"program": "${workspaceRoot}/startup.py",
"cwd": "${workspaceRoot}",
"env": {
"FLASK_APP": "${workspaceRoot}/apt-flask.py",
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python: APT FLask",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${workspaceFolder}/venv/Scripts/python.exe",
//"program": "${workspaceFolder}/venv/Scripts/flask.exe",
"module": "flask.cli",
"cwd": "${workspaceFolder}",
"env": {
"FLASK_APP": "${workspaceFolder}/apt-flask.py",
"DEBUG": 1,
"LC_ALL": "en_US.utf-8",
"LANG": "en_US.utf-8"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
settings.json
{
"python.pythonPath": "${workspaceRoot}/venv/Scripts/python.exe"
}
As far as errors go, I get no errors in the console, only the error within the editor that tells me that the "Debug adapter process has terminated unexpectedly".
I'm not sure what else to try. I currently use Pycharm but was looking for an editor that is more lightweight and as I use VS Code for other things it makes sense to change, so would be nice to finally get this working.
Any help would be brilliant.
.2018.2.0release that went out just over 2 hours ago. Please update and see if that new configuration works for you.launch.jsonand reload the python default configurations, changed"FLASK_APP": "${workspaceFolder}/apt-flask.py"and is now working as expected!. Thank you