重现步骤: 运行下面的 docker compose 文件,其中安装了 debugpy 并使用 debugpy 连接到端口 5672!
损坏的 pip——尝试将 pip 版本降级到 pip 20.0.2,但没有成功! 点版本
bash-5.1# pip --version pip 23.0 from /.venv/lib/python3.8/site-packages/pip (python 3.8)
docker-compose.yml
services:
srvr:
build:
context: ../..
dockerfile: Dockerfile
hostname: srvr
container_name: srvr
networks:
- fyndnet
entrypoint:
[
"sh",
"-c",
"pip install --upgrade debugpy && python -m debugpy --wait-for-client --listen 0.0.0.0:5672 -m entrypoint",
]
volumes:
- ../..:/srv/data
environment:
- MODE=server
env_file:
- $env_file_name
image: python:latest
tty: true
ports:
- "$Port1:8085"
- 5672:5672
Collecting debugpy
server | Downloading debugpy-1.8.1-py2.py3-none-any.whl (4.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.8/4.8 MB 1.3 MB/s eta 0:00:00
server | Installing collected packages: debugpy
server | Successfully installed debugpy-1.8.1
server |
server | [notice] A new release of pip is available: 23.0 -> 24.0
server | [notice] To update, run: pip install --upgrade pip
server | Traceback (most recent call last):
server | File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
server | return _run_code(code, main_globals, None,
server | File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
server | exec(code, run_globals)
server | File "/.venv/lib/python3.8/site-packages/debugpy/adapter/__main__.py", line 215, in <module>
server | __import__("debugpy")
server | File "/.venv/lib/python3.8/site-packages/debugpy/adapter/../../debugpy/__init__.py", line 35, in <module>
server | from debugpy.public_api import * # noqa
server | File "/.venv/lib/python3.8/site-packages/debugpy/adapter/../../debugpy/public_api.py", line 8, in <module>
server | import typing
server | File "/.venv/lib/python3.8/site-packages/debugpy/adapter/../../typing.py", line 1359, in <module>
server | class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
server | File "/.venv/lib/python3.8/site-packages/debugpy/adapter/../../typing.py", line 1007, in __new__
server | self._abc_registry = extra._abc_registry
server | AttributeError: type object 'Callable' has no attribute '_abc_registry'
server | Traceback (most recent call last):
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/api.py", line 237, in listen
server | sock, _ = endpoints_listener.accept()
server | File "/usr/local/lib/python3.8/socket.py", line 292, in accept
server | fd, addr = self._accept()
server | socket.timeout: timed out
server |
server | During handling of the above exception, another exception occurred:
server |
server | Traceback (most recent call last):
server | File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
server | return _run_code(code, main_globals, None,
server | File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
server | exec(code, run_globals)
server | File "/.venv/lib/python3.8/site-packages/debugpy/__main__.py", line 39, in <module>
server | cli.main()
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/cli.py", line 430, in main
server | run()
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/cli.py", line 302, in run_module
server | start_debugging(argv_0)
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/cli.py", line 256, in start_debugging
server | debugpy.listen(options.address)
server | File "/.venv/lib/python3.8/site-packages/debugpy/public_api.py", line 31, in wrapper
server | return wrapped(*args, **kwargs)
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/api.py", line 143, in debug
server | log.reraise_exception("{0}() failed:", func.__name__, level="info")
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/api.py", line 141, in debug
server | return func(address, settrace_kwargs, **kwargs)
server | File "/.venv/lib/python3.8/site-packages/debugpy/server/api.py", line 251, in listen
server | raise RuntimeError("timed out waiting for adapter to connect")
server | RuntimeError: timed out waiting for adapter to connect
server exited with code 1
我尝试通过执行上述 docker-compose.yml 文件来使用 debugpy 库在 VSCode 上运行调试器
pip install --upgrade debugpy && python -m debugpy --wait-for-client --listen 0.0.0.0:5672 -m entrypoint
但是,当尝试连接到端口 5672 时,我遇到了 AttributeError 并显示消息:“type object 'Callable' has no attribute '_abc_registry'”。
我期望调试库能够成功启动并等待端口 5672 上的客户端连接,以便我可以使用 VSCode 调试我的应用程序。但是由于AttributeError,连接没有建立,无法调试。
卸载打字对我有用。在您的 docker compose 中卸载该软件包。我正在使用 python 3.11,此包删除并没有破坏我的应用程序,但在应用程序中使用了打字。我猜它正在使用 python3.11 中的内置打字模块。
command:
sh -c "pip install --upgrade debugpy && pip uninstall --yes typing && python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m entrypoint