[Python] Remote debugging with debugpy works from code but not from command line

Discussão em 'Python' iniciado por Stack, Julho 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python binary (which is built using bazel but I don't think that's relevant) that I can run like this:

    $ bazel-bin/path/to/my_test

    ----------------------------------------------------------------------
    Ran 5 tests in 0.228s

    OK


    I want to use debugpy to debug this binary in Visual Studio Code. I can go the file I want to debug and add

    import debugpy
    debugpy.listen(('0.0.0.0', 5678))
    debugpy.wait_for_client()


    Build and run the binary, it starts waiting for the client, then I use this vscode config

    {
    "version": "0.2.0",
    "configurations": [
    {
    "name": "Python: Remote Attach",
    "type": "python",
    "request": "attach",
    "host": "127.0.0.1",
    "port": 5678,
    }
    ]
    }


    Everything works fine. I can put breakpoints, jump around the code, perfect.

    Now, if instead of adding the code at top, I do:

    python3 -m debugpy --listen 0.0.0.0:5678 --wait-for-client bazel-bin/path/to/my_test


    It looks like the client is waiting for connections. Then I start remote debugging on vscode and... nothing happens. The debugger starts and finishes in a second. I see no logs, no errors.

    Where can I find logs to see what's going on on either the client side or vscode?

    Continue reading...

Compartilhe esta Página