I recently upgraded to matplotlib 2.0.0 and it has this weird behavior in the interactive window where after I do a plt.show and close the interactive window, it hangs and I can't type anything. I can only type if I press control+c, but even so it takes about 15 seconds before the KeyboardInterrupt sets in and then I can type.
The behavior can be reproduced simple with this code
Apparently this only happens with IPython, since I tried in a simple python session and there was no problem. But I think it's not IPython-related because this never happened with any of the previous Matplotlib versions, just version 2. So I thought I'd post this here instead on the IPython issues.
Matplotlib version 2.0.0
Python version 2.7.12
IPython version 2.4.1
Linux Mint 18.1
get_backend() output: 'TkAgg'
which version of matplotlib were you using before? In v1.5.x, there were
some updates to the ipython hooks. Furthermore, that version of ipython is
actually quite old. I think they are on version 5.x now.
I don't think we define a minimum version where we'd expect ipython to work
with matplotlib. Perhaps we should.
On Wed, Feb 22, 2017 at 1:26 PM, tomchor ***@***.***> wrote:
Bug report
I recently upgraded to matplotlib 2.0.0 and it has this weird behavior in
the interactive window where after I do a plt.show and close the
interactive window, it hangs and I can't type anything. I can only type if
I press control+c, but even so it takes about 15 seconds before the
KeyboardInterrupt sets in and then I can type.
The behavior can be reproduced simple with this code
from matplotlib import pyplot as plt
plt.plot(range(10))
plt.show()
Apparently this only happens with IPython, since I tried in a simple
python session and there was no problem. But I think it's not
IPython-related because this never happened with any of the previous
Matplotlib versions, just version 2. So I thought I'd post this here
instead on the IPython issues.
Matplotlib version 2.0.0
Python version 2.7.12
IPython version 2.4.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8129>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-F2knxIEIpzJ1fWWHnHG_IMzvcubks5rfH2_gaJpZM4MJAyc>
.
Sorry, I forgot that information. Just updated the issue.
EDIT:
Just installed IPython 5.2.2 and the issue completely went away. I never noticed my IPython version was slow, so I never bothered to update it.
Apparently matplotlib doesn't work well with old versions of IPython. Although I never read that anywhere. Maybe there should be some note about that somewhere.
It smells like Tk is not giving up control of the process?
I can confirm that closing the window does not exit (conda has old enough versions of everything!). This is specific to Tk (qt4 works as expected).
12:18 $ ipython
WARNING: Readline services not available or not loaded.
WARNING: The auto-indent feature requires the readline library
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import matplotlib
In [2]: matplotlib.use('tkagg')
In [3]: import matplotlib.pyplot as plt
In [4]: plt.plot(range(5))
Out[4]: [<matplotlib.lines.Line2D at 0x7fd48611b290>]
In [5]: plt.show()
^C---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-5-c4e69632d98a> in <module>()
----> 1 plt.show()
/tmp/old_stuff/lib/python2.7/site-packages/matplotlib/pyplot.pyc in show(*args, **kw)
251 """
252 global _show
--> 253 return _show(*args, **kw)
254
255
/tmp/old_stuff/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in __call__(self, block)
191
192 if not is_interactive() or get_backend() == 'WebAgg':
--> 193 self.mainloop()
194
195 def mainloop(self):
/tmp/old_stuff/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.pyc in mainloop(self)
69 class Show(ShowBase):
70 def mainloop(self):
---> 71 Tk.mainloop()
72
73 show = Show()
/tmp/old_stuff/lib/python2.7/lib-tk/Tkinter.pyc in mainloop(n)
417 def mainloop(n=0):
418 """Run the main loop of Tcl."""
--> 419 _default_root.tk.mainloop(n)
420
421 getint = int
KeyboardInterrupt:
In [6]:
I'm having this issue too with Tkagg. After plt.show(), figure shows, but then closing the window hangs the console forever. But I also had this issue with matplotlib 1.5.3.
OS: Gentoo Linux amd64
Python: 3.{5,6}
IPython: 5.3.0
That makes it more likely to be a bug in the IPython tk inputhook. One of the changes is 1.5.3 is to automatically enable that if Matplotlib detects it has been imported inside of a IPython sessions (but 1.5.1 did not).
One of the possibility is to test with IPython 6 (released yesterday, Python 3 only) anduse https://github.com/ipython/rlipython as it we re-us readline and should skip the PTK eventloop. It should be backported to 5.4 but this has not been released yet.
I'm unfamiliar with Tk hooks, I'll see if I find time and manage to reproduce
I still have this issue in 2.1.0-r1. I tried with IPython 6 and rlipython as suggested, but still the terminal hangs after closing the figure. Is there any possible workaround (so I don't stay trapped in 1.5.1 :) )?
There is something funny going on with tk tear-down and probably requires someone who understands Tk to spend some time tracing exactly what is going on.
I'm having a similar problem in which matplotlib is slow after plt.show(). It takes about 10s before it opens the window. I'm on Ubuntu WSL on Windows 11. The lag only happens in the first time I plot something. Second time is fast.
These are my versions.
matplotlib 3.7.0 py311h38be061_0 conda-forge
matplotlib-base 3.7.0 py311h8597a09_0 conda-forge
matplotlib-inline 0.1.6 pyhd8ed1ab_0 conda-forge
Any idea about how to solve this problem or where/what to search?
This lag happens in both my base conda environment and a custom one. But when I log in from a different Windows user and try to do the same, there is no lag regardless of what conda environment I use. Maybe this is something in the Ubuntu WSL environment and how it communicates with the X Server? If it is, how can I solve it?
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
efiring commented on Feb 22, 2017
What operating system, and what matplotlib backend?
That's a very old IPython version; can you try with a recent version?
WeatherGod commented on Feb 22, 2017
tomchor commented on Feb 22, 2017
Sorry, I forgot that information. Just updated the issue.
EDIT:
Just installed IPython 5.2.2 and the issue completely went away. I never noticed my IPython version was slow, so I never bothered to update it.
Apparently matplotlib doesn't work well with old versions of IPython. Although I never read that anywhere. Maybe there should be some note about that somewhere.
Thanks
tacaswell commented on Feb 23, 2017
It smells like Tk is not giving up control of the process?
I can confirm that closing the window does not exit (conda has old enough versions of everything!). This is specific to Tk (qt4 works as expected).
12:18 $ ipython WARNING: Readline services not available or not loaded. WARNING: The auto-indent feature requires the readline library Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15) Type "copyright", "credits" or "license" for more information. IPython 2.4.1 -- An enhanced Interactive Python. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://binstar.org ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: import matplotlib In [2]: matplotlib.use('tkagg') In [3]: import matplotlib.pyplot as plt In [4]: plt.plot(range(5)) Out[4]: [<matplotlib.lines.Line2D at 0x7fd48611b290>] In [5]: plt.show() ^C--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) <ipython-input-5-c4e69632d98a> in <module>() ----> 1 plt.show() /tmp/old_stuff/lib/python2.7/site-packages/matplotlib/pyplot.pyc in show(*args, **kw) 251 """ 252 global _show --> 253 return _show(*args, **kw) 254 255 /tmp/old_stuff/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in __call__(self, block) 191 192 if not is_interactive() or get_backend() == 'WebAgg': --> 193 self.mainloop() 194 195 def mainloop(self): /tmp/old_stuff/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.pyc in mainloop(self) 69 class Show(ShowBase): 70 def mainloop(self): ---> 71 Tk.mainloop() 72 73 show = Show() /tmp/old_stuff/lib/python2.7/lib-tk/Tkinter.pyc in mainloop(n) 417 def mainloop(n=0): 418 """Run the main loop of Tcl.""" --> 419 _default_root.tk.mainloop(n) 420 421 getint = int KeyboardInterrupt: In [6]:malfatti commented on Apr 20, 2017
I'm having this issue too with Tkagg. After plt.show(), figure shows, but then closing the window hangs the console forever. But I also had this issue with matplotlib 1.5.3.
OS: Gentoo Linux amd64
Python: 3.{5,6}
IPython: 5.3.0
tacaswell commented on Apr 20, 2017
att @Carreau I suspect that there may be some input hook issues with tk....
malfatti commented on Apr 20, 2017
I don't know if it helps, but this issue is not on matplotlib 1.5.1.
tacaswell commented on Apr 20, 2017
That makes it more likely to be a bug in the IPython tk inputhook. One of the changes is 1.5.3 is to automatically enable that if Matplotlib detects it has been imported inside of a IPython sessions (but 1.5.1 did not).
Carreau commented on Apr 20, 2017
One of the possibility is to test with IPython 6 (released yesterday, Python 3 only) anduse https://github.com/ipython/rlipython as it we re-us readline and should skip the PTK eventloop. It should be backported to 5.4 but this has not been released yet.
I'm unfamiliar with Tk hooks, I'll see if I find time and manage to reproduce
dev-python/matplotlib: Clean old versions up
malfatti commented on Dec 5, 2017
Hello!
I still have this issue in 2.1.0-r1. I tried with IPython 6 and rlipython as suggested, but still the terminal hangs after closing the figure. Is there any possible workaround (so I don't stay trapped in 1.5.1 :) )?
Thanks :D
tacaswell commented on Dec 5, 2017
The issues #9077 #9856 #8845 may be related
The PRs
#9275 #9356 might help.
There is something funny going on with tk tear-down and probably requires someone who understands Tk to spend some time tracing exactly what is going on.
homerobse commented on Feb 17, 2023
I'm having a similar problem in which matplotlib is slow after plt.show(). It takes about 10s before it opens the window. I'm on Ubuntu WSL on Windows 11. The lag only happens in the first time I plot something. Second time is fast.
These are my versions.
matplotlib 3.7.0 py311h38be061_0 conda-forge
matplotlib-base 3.7.0 py311h8597a09_0 conda-forge
matplotlib-inline 0.1.6 pyhd8ed1ab_0 conda-forge
Any idea about how to solve this problem or where/what to search?
homerobse commented on Feb 17, 2023
This lag happens in both my base conda environment and a custom one. But when I log in from a different Windows user and try to do the same, there is no lag regardless of what conda environment I use. Maybe this is something in the Ubuntu WSL environment and how it communicates with the X Server? If it is, how can I solve it?
github-actions commented on Feb 19, 2024
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
jklymak commented on Feb 19, 2024
I'll close this. If someone has a modern slowness issue please open a new report.