VsCode python 调试报错 ERROR: Error loading ASGI app. Could not import module “main“. 解决方法
这种情况需要我们再调试的时候配置 launch.json。加载ASGI应用出错。无法导入“main”模块。选择后,设置启动文件,然后点击回车。报错了,注意看第一行跟报错信息,提示。重新运行下,可见已经成功了。
·

选择后,设置启动文件,然后点击回车
root@eeb0a78c1056:~# /usr/bin/env /bin/python /root/.vscode-server/extensions/ms-python.debugpy-2024.14.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 60741 -- -m uvicorn main:app --reload
INFO: Will watch for changes in these directories: ['/root']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [2469] using StatReload
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
ERROR: Error loading ASGI app. Could not import module "main".
报错了,注意看第一行跟报错信息,提示

ERROR: Error loading ASGI app. Could not import module "main".
加载ASGI应用出错。无法导入“main”模块。

这种情况需要我们再调试的时候配置 launch.json

"cwd":"${workspaceFolder}/py"
重新运行下,可见已经成功了
断点调试捕捉成功

更多推荐




所有评论(0)