-
Notifications
You must be signed in to change notification settings - Fork 137
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
Debugging scripts that use matplotlib interactively on vscode.... #603
Comments
This happens because
and that's skipped when @awa5114 A simple workaround for now would be calling that method yourself. i.e.: until this issue is fixed, you can add to the start of your code something as:
|
Yes... it works thank you. Would be nice to not have to copy paste this code in every .py file I work on. Is there a cleaner way? I guess I could paste that code in a separate file and import it, but I was wondering whether I could just have this as a sort of global setting on vscode? |
@fabioz Can we add this to launch json setting, pass this through to pydevd? |
@karthiknadig that would be awesome... if there's anything I can do to help please let me know. |
@karthiknadig this is actually always activated in |
@fabioz its not done by default, thats why I opened this issue... |
I meant that it's always activated on |
@fabioz Ah I see. It would have to be implemented in the Is there a temporary solution? i.e. a way to eliminate that try except block from my code but somehow ensure the behavior occurs while debugging? Does the |
Well, some options to always launch that could be doing a custom sitecustomize or locally changing i.e.: run the following in the debugger:
Then, open that file and change the function:
at the end of that function (before the comment |
Hmmm... I feel a bit uncomfortable modifying source files like that. Was hoping a solution might exist more at the vscode level. Is there really no other option but modifying the source code? If so can I submit a pull request containing that change such that it can be included in future releases of vscode? |
You can create the custom sitecustomize.py to add that workaround, which I also mentioned (see: https://docs.python.org/3/library/site.html for more details). I'll actually provide a fix for this before the next release anyways (it's really a one line change, I just have to decide on the better place to have that, so, having the pull request wouldn't really help me here -- although it's probably where I mentioned before I need to check whether this is ok in all possible scenarios)... the workaround is so that you can have it working right now in your computer. You can do it in your own code through a sitecustomize.py, change the debugger directly or just change your code directly where you need it. I'm not aware of a different solution at the vscode level. |
@fabioz fair enough. I see that you have already added the relevant code. If I uninstall/reinstall or update the extension, should it now work as expected? At which point does the change get incorporated into the extension itself such that stupid users like me can make use of it :P ? |
@fabioz sorry to bug you but would it be possible to get a response on the above comment? |
Sorry about the delay... I don't really know when a new @karthiknadig do you have any insight here? As a note, if you want, you can get the current version in the repo and use it until an official version with this fix is released. i.e.:
Then, in your launch config add to your launch configuration:
|
This is not released yet. We have not published a new version of
|
Thanks! I will try it. |
I tried this (on Windows 10) and I get: |
@cactus1549 Can you share the command you ran? This will happen if |
Hi, I used
I just tried your suggestion and this is what I got:
|
@cactus1549 Try this looks like there was a mistake in the path:
I fixed the path in my original comment. |
I used
the matplotlib Figure displays empty, so it's effectively impossible to debug figures interactively. |
@cactus1549 I just picked this thread. Version 1.5.1 (which is the last one released at Oct/2021) already had the changes, so, it's not surprising your case also isn't working with the current version... Can you create a new issue regarding your use case? Please also include the output of running:
|
Hi @fabioz,
|
You can create it in this repository (https://github.com/microsoft/debugpy/) which is related to debugger issues in vscode-python. |
Environment data
python.languageServer
setting: I don't think this is related to my issueExpected behaviour
Would like to debug script that uses matplotlib interactively. By interactively I mean placing a break point and watching my figure update as I actually step through my code. PyCharm has this behavior out of the box and it is extremely useful.
Actual behaviour
Stepping through a script using matplotlib will not generate an interactive figure.
Steps to reproduce:
Create a file called test.py and paste the following code:
Place a breakpoint on line 4, create a standard debug configuration and start the debugger. Step over lines 4, 5, and 6. No plot appears.
The text was updated successfully, but these errors were encountered: