我一直试图让调试器在VS Code中工作,以便可以调试Flask App。我尝试了太多的选择,launch.json
以至于我觉得自己已经一无所有。
以下示例不起作用:https : //github.com/DonJayamanne/pythonVSCode/wiki/Debugging : -Flask
在Visual Studio代码中调试Flask(Python)Web应用程序
以下是我launch.json
和setting.json
。当我尝试多种变体时,启动文件中有两种配置。
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" }
至于错误,控制台中没有错误,只有编辑器中的错误告诉我“调试适配器进程已意外终止”。
我不确定还有什么尝试。我目前使用Pycharm,但是我正在寻找一种更轻便的编辑器,并且由于我将VS Code用于其他用途,因此有必要进行更改,因此最终使它正常工作将是一件很不错的事情。
任何帮助都是很棒的。