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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM