Python 3.x 使用Visual Studio代码远程调试python代码时出错
MacOS:10.15.6 Visual Studio代码:1.49.1 launch.json:Python 3.x 使用Visual Studio代码远程调试python代码时出错,python-3.x,docker,visual-studio-code,remote-debugging,Python 3.x,Docker,Visual Studio Code,Remote Debugging,MacOS:10.15.6 Visual Studio代码:1.49.1 launch.json: { "version": "0.2.0", "configurations": [ { "name": "Python: Remote Attach", "type": "python&qu
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"logToFile": true,
"justMyCode": false,
"outputCapture": "std",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
]
}
]
}
Docker命令
docker run--名称faber--rm-it-p 0.0.0.0:8020-8027:8020-8027-p 8028:8028
Visual Studio代码日志文件
0 Starting Session:
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"logToFile": true,
"justMyCode": false,
"outputCapture": "std",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "/Users/j.bora/work/bsi/Blockchain/identity-and-access-management/aries-cloudagent-python",
"remoteRoot": "/Users/j.bora/work/bsi/Blockchain/identity-and-access-management/aries-cloudagent-python"
}
],
"debugOptions": [
"DebugStdLib",
"RedirectOutput",
"UnixClient",
"ShowReturnValue"
],
"showReturnValue": true,
"workspaceFolder": "/Users/j.bora/work/bsi/Blockchain/identity-and-access-management/aries-cloudagent-python"
}
1 Client --> Adapter:
{
"command": "initialize",
"arguments": {
"clientID": "vscode",
"clientName": "Visual Studio Code",
"adapterID": "python",
"pathFormat": "path",
"linesStartAt1": true,
"columnsStartAt1": true,
"supportsVariableType": true,
"supportsVariablePaging": true,
"supportsRunInTerminalRequest": true,
"locale": "en-us",
"supportsProgressReporting": true
},
"type": "request",
"seq": 1
}
3 Error:
{}
5 Client --> Adapter:
{
"command": "disconnect",
"arguments": {
"restart": false
},
"type": "request",
"seq": 2
}
6 Error:
{
"code": "EPIPE"
}
2508 Stopping Session
如上面的日志文件所示,我得到了EPIPE错误。此外,调试器不会附加到远程docker进程。请有人告诉我这个错误是怎么回事。谢谢。当我让调试器在容器内部而不是0.0.0上侦听本地主机时,我遇到了相同的问题,例如:
python -m debugpy --listen localhost:5678 myfile.py
在0.0.0.0上运行它解决了以下问题:
python -m debugpy --listen 0.0.0.0:5678 myfile.py