import os
import debugpy
os.environ['PYDEVD_DISABLE_FILE_VALIDATION'] = '1'
if os.environ.get('DEBUG','false').lower().strip() == 'true':
debugpy.listen(("localhost", 5678))
print("Waiting for debugger attach on port 5678...")
debugpy.wait_for_client()
print("Debugger attached!")
这是我的VSCODE启动。
{
"version": "0.2.0",
"configurations": [
{
"name": "Serverless Debug",
"type": "python",
"request": "attach",
"port": 5678,
"host": "localhost",
"console": "integratedTerminal",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
// ,
// "pythonArgs": [
// "-Xfrozen_modules=off"
// ]
}
]
}
也尝试了这一点:
{
"version": "0.2.0",
"configurations": [
{
"name": "Serverless Debug",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
]
}
]
}
其他人经历过吗?
我似乎有同样的问题。我也没有进行任何更改或更新,并且在通过debugpy.listen()添加调试器时无法再附加。从VSCODE(不通过听力)启动调试器的工作原理。
在听()后,我还得到了“ Lost sys.stderr”,我以前从未遇到过。help表示赞赏!