[英]python scripts debug in ROS with Visual Studio Code
為了調試python腳本,我想在python調試器開始之前運行“ source path_to / setup.bash”。 我應該怎么做? 謝謝!
VSCode使您可以通過在preLaunchTask
中設置 preLaunchTask
來執行此 launch.json
您需要的是一個task.json
,其type
設置為shell
。 看起來像這樣。
task.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "prerun",
"type": "shell",
"command": "source hello.sh" // your shell command here
}
]
}
記住標簽“ prerun”。 現在在launch.json
, alt 啟動配置中 ,將此標簽設置為preLaunchTask
例如
launch.json
{
// 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 Experimental: Current File (Integrated Terminal)",
"type": "pythonExperimental",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"preLaunchTask": "prerun"
},
]
}
您可以根據需要定制調試配置。 對於上面的示例,每次在Python源文件作為編輯器處於調試狀態時,它都會預啟動hello.sh
。 現在切換到您的Python代碼並繼續調試。 希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.