下载的源码总会遇到这样启动的:
并且发现shell文件内容很多,比较复杂,比如:

这时候想要调试,可以通过端口连接的方式调试,具体方法如下:
{
"name": "Python: 远程附加",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
],
"justMyCode": true
}
python classify.pypython -m debugpy --listen 5678 --wait-for-client classify.py调试时:
正常在控制台运行sh文件,等一下,然后点击vscode中的调试按钮。
如果运行sh文件需要进入项目中某一个文件夹这种情况,比如:
cd scripts
bash run.sh
这时候我们还需要更改调试文件launch.json中pathMappings字段的localRoot为脚本运行目录:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 远程附加",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/scripts",
"remoteRoot": "."
}
],
"justMyCode": true
}
]
}