====== python远程调试 ====== ===== vscode里远程调试 ===== # 安装远程调试工具 pip install debugpy # 启动4005远程调试端口, 此时程序会卡住,等待远程连接 python3 -m debugpy --listen 0.0.0.0:4005 --wait-for-client scripts/ctbots.py 在 vscode的工程里,直接添加 .vscode/launch.json 添加配置: { "version": "0.2.0", "configurations": [ { "name": "Docker Remote Debug", "type": "python", "request": "attach", "port": 4005, "host": "192.168.1.1", "pathMappings": [ { "localRoot": "${workspaceFolder}", // 本地代码路径 "remoteRoot": "/home/ctbots/my-debug-project" // 容器内代码路径(需与容器内一致) } ] } ] } ===== 可能遇到的问题 ===== packages/debugpy/adapter/../../typing.py", line 1007, in __new__ self._abc_registry = extra._abc_registry AttributeError: type object 'Callable' has no attribute '_abc_registry' 兼容性问题,处理下 typing库 pip uninstall typing -y pip install --upgrade typing-extensions