vscode中调试python,找不到程序当前目录的包

module not found error, how python interpreter find modules:

  • The directory from which the input script was run, or the current directory if the interpreter is being run interactively
  • The list of directories contained in the PYTHONPATH environment variable, if it is set. (The format for PYTHONPATH is OS-dependent but should mimic the PATH environment variable.)
  • An installation-dependent list of directories configured at the time Python is installed

change "cwd" option in vscode's launch.json: (设置为要运行的python脚本的目录)

"cwd":"${workspaceFolder}/tasks/human_pose", 
 
how to launch the python program in vscode with new system Terminal: (在新的系统终端中运行,而不是VS code内置终端)
set "console" to  "console": "externalTerminal"
 
in C++'s launch.json, it should be : 
"externalConsole": true,

 

 

ref:

https://realpython.com/lessons/module-search-path/

https://code.visualstudio.com/docs/python/debugging#_set-configuration-options

https://code.visualstudio.com/docs/cpp/launch-json-reference

posted @ 2021-06-29 17:00  略略略——  阅读(1188)  评论(0编辑  收藏  举报