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