我使用
"type": "python"
来调试远程 python 服务器。现在我在 launch.json
: 中看到此警告
此配置很快就会被弃用。请将
替换为python
以使用新的 Python 调试器扩展。debugpy
我原来的设定:
{
"type": "python",
"request": "attach",
"name": "attach remote",
"host": "192.168.1.101",
"port": 8765,
"pathMappings": [
{
"localRoot": "${workspaceFolder}/...",
"remoteRoot": "/usr/app/..."
}
],
"justMyCode": false
},
当我切换到
"type": "debugpy"
时,我在“端口”和“主机”字段上收到以下错误:
不允许使用属性端口。
那么问题来了:如何添加端口和主机信息来完成调试配置的迁移?
事实证明这非常简单:将
"port"
和 "host"
属性替换为 "connect"
,所以如果您的配置是:
{
"type": "python",
"request": "attach",
"name": "attach remote",
"host": "192.168.1.101",
"port": 8765,
"pathMappings": [
{
"localRoot": "${workspaceFolder}/...",
"remoteRoot": "/usr/app/..."
}
],
"justMyCode": false
},
变成:
{
"type": "python",
"request": "attach",
"name": "attach remote",
"connect": { "host": "192.168.1.101", "port": 8765 },
"pathMappings": [
{
"localRoot": "${workspaceFolder}/...",
"remoteRoot": "/usr/app/..."
}
],
"justMyCode": false
},