-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem running debugpy in embedded python interpreter #262
Comments
dumb question - do we need the specific sys.executable that the process/app running is using, or for the purposes of this, do we just need a valid python interpreter to mediate the comms back and forth? |
@tanant In the case mentioned above it is needed for comms. For the above case, attach using process id would probably work. Essentially start debug adapter in server mode.
Then from VSCode, use the following to connect:
This way you will use the python executable for comms with VS Code, and it should be able to load the debugger where the embedded python. This uses a different pathway where we don't try to start the python executable. |
I found the same thing. This was my solution. It's absolutely not art: https://github.com/puremourning/vimspector/blob/master/python3/vimspector/developer.py#L23 |
Well, I think that as @karthiknadig mentioned, the approach currently supported in this case is the attach by pid. I think that we could extend that to accept a One thing to note though is that we don't support automatically attaching to subprocesess in this case (we check if the executable basename has |
This kind of stuff should go into What's not clear to me is why the adapter running under a custom host in this case. It's a separate process from the debugged app, and it kinda expects to be run using a regular interpreter. But it then applies "python" from launch.json to start the debuggee (and only falls back to |
we're calling
This is an "attach" scenario. |
Ahh, that makes perfect sense now. Yes, we should just make this configurable. |
What we want here is really the same thing as "python" config property in the launch scenario, except it needs to be applied before the client has a chance to connect and transmit the configuration in the "attach" request. That's exactly why we added So we should just support "python" in |
A possible workaround for Windows is to use |
I have the same problem with ArcGIS Pro and Python Toolbox Tools. Until June 2020 I used ptvsd with "attach" and that worked fine. Environment:
|
This is not gonna work for those who are using a python embedded in certain applications, for example in Autodesk Maya, where the python to execute is actually named "mayapy.exe" and mayapy.exe is not even in sys.exec_prefix... Speaking about Maya... this issue is blocking the entire VFX and Gaming industry from using debugpy and consequentially Visual Studio Code for debugging. |
The workaround is to temporarily mock exe = sys.executable
try:
sys.executable = "C:/path/to/any/working/python.exe"
debugpy.listen( port )
finally:
sys.executable = exe Specifically, it can just be a completely different python installation. I recommend installing python of the same major version on the machines you need to debug, if that works for you. |
@daniele-niero This was just a proposed default for the case where |
Just to mention I ran into this issue recently when trying to see if debugpy would work with freecad (the latest 0.19 one that uses python 3) since it also has an embedded python interpreter |
#387 is now merged, and you can do |
I had this issue with Maya and after spending few hours reading all these comments I ended up with 2 solution: 1- using import debugpy
debugpy.configure(python="<path_to_maya_python>/mayapy")
debugpy.listen(5678)
debugpy.wait_for_client() 2- using old import ptvsd
ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)
ptvsd.wait_for_attach() I really prefer it to work out of the box like in I am just wondering how difficult it is to implement\transfer the same behavior from |
Environment data
Actual behavior
Remote debugging works running it in a python environment in a shell. But when run through an application with embedded python interpreter it starts a new instance of this application and it cannot connect.
I think the problem is that
sys.executable
is not returning the path to the python interpreter but the path of the application executable itself. And because of this the arguments passed with subprocess are not recognized.debugpy/src/debugpy/server/api.py
Line 103 in 7a2891b
If I replace
sys.executable
with the path to the embedded interpreter remote debugging works as expected.An older version of ptvsd worked out of the box btw: microsoft/ptvsd@0825dbe
The text was updated successfully, but these errors were encountered: