[Python] Attaching a VSCode Debugger to a Sub Process in Python

Discussão em 'Python' iniciado por Stack, Novembro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have a script that effectively does the following:

    top_script.py:

    os.system("bash_script.sh")


    bash_script.sh

    python3 child_script.py


    child_script.py

    # Actual work goes here


    In VSCode, I love the integrated debugger, but when I follow their advice[1] when launching from the IDE, I get "ECONNREFUSED 127.0.0.1:5678".

    When I execute the following from the integrated terminal in VSCode, it runs without the errors, but it doesn't stop on breakpoints in child_script.py.

    python3 -m debugpy --listen 5678 top_script.py


    How can I execute the top script first (either from the IDE or command line) and have breakpoints I attach in child_script.py be rendered in VSCode?

    [1] https://code.visualstudio.com/docs/python/debugging

    Continue reading...

Compartilhe esta Página