为了调试python脚本,我想在python调试器开始之前运行“ source path_to / setup.bash”。我应该怎么做?谢谢!
VSCode允许通过设置这样做一个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
,中高音启动配置,设置这个标签作为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"
},
]
}
您可以根据需要定制调试配置。对于上面的示例,hello.sh
每次Python源文件是编辑器处于调试状态时,它都会预先启动。现在切换到您的Python代码并继续调试。希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句