python—远程调试

1、安装插件

插件名称:Remote – SSH

2、配置插件

Host 192.168.58.43
  HostName 192.168.58.43
  Port 22
  User linaro
  PreferredAuthentications publickey
  IdentityFile "C:\Users\98350\.ssh\linaro"
  ForwardAgent yes
  • IdentityFile:指定ssh的私钥
  • PreferredAuthentications:指定登录验证方式为公钥

3、在debug的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 Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "args": [
                "--rkllm_model_path",
                "/sata/ai/npu/DeepSeek-R1-Distill-Qwen-1.5B.rkllm",
                "--target_platform",
                "rk3588"
            ],
            "console": "integratedTerminal",
            # 通过设置环境变量来改变端口号
            "env": {
                "PORT": "25388"
            }
        }
    ]
}

4、错误

需要删除完程服务器上的vscode工作目录

rm .vscode-server/

注意:在远程调试时,一定要指定debug运行时的python虚拟环境,否则会报各种依赖错误