Problems with Interactive Plotting in Debug Mode in PyCharm Version 2017.1

Completed

In earlier Versions of PyCharm it was possible to interactively plot a figure with matplotlib in the debug console without blocking the console. Example:

  • plt.imshow(2dgrid) 

directly opened the figure. I could do it several times to look at different results while in debugging mode.

 

Since 2017.1 I have to manually call show() which then blocks the console until the figure is destroyed. Example: 

  • plt.imshow(2dgrid) 
  • plt.show() 

Without plt.show() the figure does not open up. Additionallay plt.show() blocks the console. Trying plt.show(block=False) crashes the figure. Process finished with exit code -805306369 (0xCFFFFFFF)

I hope my problem is comprehensible. Is this a bug under Version  2017.1? 

4
9 comments
Official comment

HI there

Thank you for reaching out, 

As this issue requires thorough investigation, please create an issue on YouTrack (https://youtrack.jetbrains.com/issues/PY).

Please attach all relevant information for quicker resolution (including screenshots demonstrating it along with IDE logs from Help | Collect Logs and Diagnostic Data).

 

Kind regards,

 

Avatar
Permanently deleted user

I am having the exact same problem.  Makes me regret switching to 2017.1 from 2016.3 because I use plotting in the debugger as my primary tool.

0
Avatar
Permanently deleted user

There is already a solution for this problem:
https://youtrack.jetbrains.com/issue/PY-23413

In PyCharm go to:

  • Run --> Edit Configurations --> Add Environment Variabes "Display True"

2
Avatar
Permanently deleted user

works for me now, thanks for pointing to the solution.

0
Avatar
Permanently deleted user

I am still having troubles with matplotlib, even doing what is recommended here. I need help.

9
Avatar
Permanently deleted user

You can show the plots in a separate window using the hint from https://youtrack.jetbrains.com/issue/PY-26652:

.... Check you have an option "Show plots in toolwindow" enabled in Settings | Tools | Python Scientific. After that you can run a script which contains pyplot.show() call and your graph will appear in a tool window "SciView". 

0

I am also facing this problem on version  PyCharm 2021.3.1 (Community Edition). And the fix (adding env, DISPLAY = True) does not help.

And it seems below link is also broke.

https://youtrack.jetbrains.com/issue/PY-26652:

Can someone help me on this ?

 

 

 

0

Having this issue with 2024.1 IntelliJ IDEA (Community Edition). 

2

This issue still exists in PyCharm 2024.3.5 (Community Edition). 

I have a fresh Conda env with PyQt 6 and Matplotlib 3.10, and plotting in the Python console doesn't work.

import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()

A window is opened but it remains black and unresponsive. The only way to get rid of it is to reload the Python console.
The QtAgg backend is correctly loaded, as shown by matplotlib.get_backend().
I also tried this in a command prompt and it works, no issues on the end of the environment.

I have tried the plt.show(block=True) workaround and this does in fact work - the plot shows and I can interact with it. This is not a solution though, as it blocks the console. 

The suggested Display=True workaround  (here: https://youtrack.jetbrains.com/issue/PY-23413) does have an effect: it makes it worse. Now when I reload the console and import matplotlib, the backend is Agg. Trying to load the QtAgg backend results in an error:
ImportError: Cannot load backend 'QtAgg' which requires the 'qt' interactive framework, as 'headless' is currently running

This used to work at some point. This functionality seems rather fundamental.

0

Please sign in to leave a comment.