[英]Unable to debug Flask app in Visual Studio Code
I have a currently working flask app.我有一个当前正在运行的烧瓶应用程序。 I want to debug it in Visual Studio Code.我想在 Visual Studio Code 中调试它。 I keep hitting errors that I can't google my way out of.我不断遇到我无法通过谷歌解决的错误。 I have gone through How do I debug Flask App in VS Code and the video, it did not solve my inability to debug.我已经阅读了如何在 VS Code 中调试 Flask App和视频,它并没有解决我无法调试的问题。 I have also copied the instructions from https://code.visualstudio.com/docs/python/tutorial-flask and I was able to debug in a new example file!我还从https://code.visualstudio.com/docs/python/tutorial-flask复制了说明,并且能够在新的示例文件中进行调试! But I can't translate this success to my current project that I cannot debug.但是我无法将这种成功转化为我无法调试的当前项目。 The main error line seems to be ModuleNotFoundError: No module named 'app' .主要错误行似乎是ModuleNotFoundError: No module named 'app' 。 Or perhaps that isn't the error, I can't tell.或者也许这不是错误,我不知道。 If any further information is needed please state so, I don't want to plaster endless error messages.如果需要任何进一步的信息,请说明,我不想粘贴无休止的错误消息。
Also my launch.json is correctly copied/formatted based off both the visual studio code tutorial and from Miguel's(the first link).此外,我的 launch.json 是根据 Visual Studio 代码教程和 Miguel 的(第一个链接)正确复制/格式化的。 The end goal is to step through the visual studio code debugger successfully.最终目标是成功通过 Visual Studio 代码调试器。
C:\Users\OMITTED\Documents\project>cmd /C "set "PTVSD_SESSION_ID=1" && set "PTVSD_LAUNCHER_PORT=59672" && C:\Users\OMITTED\AppData\Local\Programs\Python\Python37\python.exe c:\Users\OMITTED\.vscode\extensions\ms-python.python-2019.11.50794\pythonFiles\lib\python\new_ptvsd\wheels\ptvsd\launcher -m flask "
Traceback (most recent call last):
File "C:\Users\OMITTED\AppData\Local\Programs\Python\Python37\lib\site-packages\flask\cli.py", line 240, in locate_app
__import__(module_name)
ModuleNotFoundError: No module named 'app'
Continued ->续->
Traceback (most recent call last):
File "C:\Users\OMITTED\AppData\Local\Programs\Python\Python37\lib\site-packages\flask\cli.py", line 556, in list_commands
rv.update(info.load_app().cli.list_commands(ctx))
File "C:\Users\OMITTED\AppData\Local\Programs\Python\Python37\lib\site-packages\flask\cli.py", line 388, in load_app
app = locate_app(self, import_name, name)
File "C:\Users\OMITTED\AppData\Local\Programs\Python\Python37\lib\site-packages\flask\cli.py", line 250, in locate_app
raise NoAppException('Could not import "{name}".'.format(name=module_name))
flask.cli.NoAppException: Could not import "app".
Usage: python -m flask [OPTIONS] COMMAND [ARGS]...
I changed my "env":{"FLASK_APP"= LOCATION}
我改变了我的"env":{"FLASK_APP"= LOCATION}
LOCATION
is the entire source path to your root app.py
. LOCATION
是根app.py
的整个源路径。
AKA C:\\Users\\Folder\\Folder\\app.py
but use \\\\
instead of \\
when answering in code. AKA C:\\Users\\Folder\\Folder\\app.py
但在代码中回答时使用\\\\
而不是\\
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.