解决vscode中使用debuger运行app.py但是报错No module named app的方法
报错的原因是:debuger的时候 会自动先cd到某个动作路径
但是这个工作路径不一定有app.py这个文件
所以你要做的是修改launch.json文件的cwd属性
改为有app.py文件的路径:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Python Debugger: Current File”,
“type”: “debugpy”,
“request”: “launch”,
“program”: “ f i l e " , " c o n s o l e " : " i n t e g r a t e d T e r m i n a l " , " c w d " : " {file}", "console": "integratedTerminal", "cwd": " file","console":"integratedTerminal","cwd":"{workspaceFolder}/simulate_network_attack_front_docs/CyberBattleSim-main/server”
}
]
}
这样即可