You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
debugpy.configure(python=) is not properly documented #1097
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
debugpy version: XXX (run import debugpy; print(debugpy.__version__) if uncertain)
OS and version: XXX
Python version (& distribution if applicable, e.g. Anaconda): XXX
Using VS Code or Visual Studio:
Actual behavior
The parent program seemingly recursively gets created and started as a process without any easy way to kill the large number of processes created.
Expected behavior
It attached and works...
Steps to reproduce:
Embed python into a program using the C API.
Make a top level script that includes debugpy debugging... import debugpy, debugpy.listen, debugpy.wait_for_client, etc..
Have parent program run and execute the top level script.
Not sure if this is a bug or is explained elsewhere. I am not going to spend the time to get involved and go through the forum. I am only leaving this here as a "gotcha" for a lonely passerby who ends up in the same scenario. Please edit / move as necessary.
In my use case, I want debugpy debugger support in a hosted (embedded) python environment. The user calls the user program and not python.exe. As such, sys.executable gets set to the exe of the program and not the expected python.exe. Why does this cause an infinite process recursion or fail to connect to the client debugger?
That would be why.
Moral of the story is.. make sure your sys.executable is set to python.exe in the hosted environment before using debugpy with the listening setup.
This is by design, but you're right, it's poorly documented. You don't have to set sys.executable, though - instead, you can configure from the app like so:
importdebugpydebugpy.configure(python="...")
(you can wrap the import in a try/except/else block so that it works regardless of whether you're debugging)
Hi, I'd like to work on this. I'll submit a PR shortly documenting how to configure the Python executable for embedded hosts before starting the listener.
Activity
int19h commentedon Oct 24, 2022
This is by design, but you're right, it's poorly documented. You don't have to set
sys.executable, though - instead, you can configure from the app like so:(you can wrap the import in a try/except/else block so that it works regardless of whether you're debugging)
Let's use this issue to track documentation.
[-]Must set sys.executable if embedding python[/-][+]debugpy.configure(python=) is not properly documented[/+]LostTime76 commentedon Oct 24, 2022
Oh, I didn't realize there was a configure function that I could call to set that.
Thanks, I will start using that mechanism.
nightcityblade commentedon Aug 18, 2026
Hi, I'd like to work on this. I'll submit a PR shortly documenting how to configure the Python executable for embedded hosts before starting the listener.