4

I am using Windows 7 64-bit with PyCharm 2016.3.2, build #PY-163.10154.50, built on December 28, 2016.

I have a very simple script Test.py which is shown below:

import matplotlib.pyplot as plt
import ipdb

plt.ion()

x = [1, 2, 3]
plt.figure()
plt.plot(x)
plt.show()

ipdb.set_trace()

When I execute the script from the Windows Terminal using the command python Test.py, the script runs fine: I am taken to the ipdb console, where I can create and plot new variables while interacting with the generated plot. Additionally, if I run the script by first opening iPython in the Windows Terminal and calling ipython and then calling exec(compile(open('Test.py', "rb").read(), 'Test3.py', 'exec')) in the iPython console, it still runs fine. Finally, when I execute the script in either of these ways from the Terminal interface in PyCharm, it still runs fine.

I run into issues when I want to run the script from the Python Console interface in PyCharm. The console opens with a message

"E:\Program Files\Anaconda3\python.exe" "E:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py"

and shows me that it is running IPython 5.1.0 with Python 3.5.2 | Anaconda 4.2.0 as the interpreter. When I use the same exec command above in this console, the code runs up 'til the breakpoint, but the figure does not render and the figure window freezes. Please see the figure below:

enter image description here

If I use plt.pause(10), the figure renders but freezes again after 10 seconds. During these 10 seconds, I can interact with the figure, but I cannot create or probe any variables with code (I am prompted by a PyCharm pop-up that the previous command is still running). Moreover, when plt.pause finishes, I receive a warning:

E:\Program Files\Anaconda3\lib\site-packages\matplotlib\backend_bases.py:2437: MatplotlibDeprecationWarning: Using default event loop until function specific to this GUI is implemented warnings.warn(str, mplDeprecation)

At any time, if I try to make new figures from the ipdb console, they also do not render and the window remains frozen until I execute plt.pause (i.e. plt.pause must be executed after any figure is created or modified).

How can I fix this issue so I can utilize the convenience of the Python Console interface in PyCharm while interacting with plots and creating/modifying variables?

Vivek Subramanian
  • 1,174
  • 2
  • 17
  • 31
  • I have the same question here, I'm using spyder IDE under Windows, matplotlib's image window showns as standard alone window(not the inline window under the ipython). I have add the `plt.ion() # enables interactive mode` followed the way suggest here: https://stackoverflow.com/a/458295/154911 , but still no luck. – ollydbg23 Sep 26 '17 at 05:06

0 Answers0