You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When producing a small plot in the console, the console becomes very sluggish afterwards:
λ python
Python 2.7.10 |Continuum Analytics, Inc.| (default, Sep 15 2015, 14:26:14) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3], marker="o")
[<matplotlib.lines.Line2D object at 0x0000000008DB60B8>]
# from here on it's sluggish until I exit -> typing shows the next character
# with a noteable delay and c&p is kind of "typing" the text instead of
# almost instantly there
>>> plt.show()
This a clean new conda env py2.7 (conda create -n mew_test python matplotlib seaborn ipython) on windows7, 64bit. I also have cmder installed, but it also happens in the default cmd console
When producing a small plot in the console, the console becomes very
sluggish afterwards:
λ python
Python 2.7.10 |Continuum Analytics, Inc.| (default, Sep 15 2015, 14:26:14) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
import matplotlib.pyplot as plt
plt.plot([1,2,3], marker="o")
[<matplotlib.lines.Line2D object at 0x0000000008DB60B8>]
[ from here on it's sluggish until I exit -> typing shows the next character with a noteable delay and c&p is kind of "typing" the text instead of almost instantly there]
plt.show()
This a clean new conda env py2.7 (conda create -n mew_test python
matplotlib seaborn ipython) on windows7, 64bit. I also have cmder
installed, but it also happens in the default cmd console
—
Reply to this email directly or view it on GitHub #5159.
Using Agg as a backend does not have this problem (no sluggish typing after plt.plot()), but on the other hand I also do not get a plot shown after plt.show() . Not sure how to get a plot window with that backend?
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
#not sluggish afterwards :-)
plt.show() # does not bring up the plotting window :-(
(It seems that I never really learned how to use matplotlib in another environement than the ipython notebook...)
I've run from PyQt4 import QtGui and didn't notice a slowdown afterwards. Running %matplotlib qt in an ipython console (not qt, not notebook!) also didn't change anything.
when you say "also didn't change anything", do you mean that it is slow
just like at the repl, or that it is normal speed, just like using Qt4
normally?
I've run from PyQt4 import QtGui and didn't notice a slowdown afterwards.
Running %matplotlib qt in an ipython console (not qt, not notebook!) also
didn't change anything.
—
Reply to this email directly or view it on GitHub #5159 (comment)
.
I would just use the IPython shell then 😉. It takes care of many of the annoying details about setting up interactive mode and managing the gui event loop.
It happens in both python and ipython. Unfortunately I currently don't have access to a different windows box, to test if it's specific to my box or to windows. :-(
Is the tkagg backend available? E.g. in ipython, %matplotlib tk.
I suspect your problem with qt involves a library conflict with something else installed on your machine. If it were a universal problem with Anaconda python 2.7 on Windows, I think Continuum would have been deluged with complaints by now, and I don't think I have seen this one on the anaconda mailing list.
I also remember that using ipython would we the fix, but this is not the case. Note that figure doesent have to be show, the slowdown happens after calling plot.
Using %gui qt in ipython before seems to be fixing the issue.
I also remember that using ipython would we the fix, but this is not the
case. Note that figure doesent have to be show, the slowdown happens after
calling plot.
—
Reply to this email directly or view it on GitHub #5159 (comment)
.
The mpl policies was always that if you want have interactive plots in the repl working without any haggle one has to use ipython. This is still true, as long either %gui or %matplotlib is called. As long all the input-hook experience is in the ipython team it is properly the best way, even if having the code directly in mpl would be also nice.
Ok, I tested it with %matplotlib tk and it doesn't become sluggish. I will create a new test env for the newer matplotlib version and then see what happens there...
before plt.plot(), I can paste long lines (2k words of lorem ipsum), but the python interpreter goes to 100% CPU (on one core) and it takes a while to paste the complete line (but not as slow as with plot)...
after plt.plot(), I can't paste long lines anymore: the interpreter has no CPU, but only 4 chars are shown (=hang?). I have to kill the interpreter (via proc explorer) to get the rest of the chars displayed (in cmd!). Shorter texts can be pasted (I tried with 230 chars), it's much slower as without the plot call but the interpreter (and cmd/...) does not use much CPU (~1% of one core).
You need to use Ipython and call %matplotlib your_backend to get non sluggish behaviour. Else the eventloop and pythons inputhook won't play nice with each other.
Using %gui qt in ipython before the plt.plot() prevents the sluggishness (=c&p is fast afterwards). Even calling this after plt.plot() (and observing sluggish behaviour) is restoring the fast c&p behaviour.
So what this means is that using matplotlib in interactive mode on windows will result in sluggish behaviour unless setting the backend to something else than qt4 or using ipython and %gui qt?
Yeah, but please note that it is not maplotlibs fault, try:
from PyQt4 import QtGui
app = QtGui.QApplication([])
and you will see the same behaviour. IPython jumps through some hoops to circumvent that. Note that QtCore.pyqtRemoveInputHook() fixes the sluggishness, but i don't know the downsides of it.
Not sure if there is any actionable item here, if matplotlib doesn't want to implement the same workaround as IPython. I think the only thing which makes sense is a warning ala "Use ipython and %gui qt" on import if _onwindows and backend=="QT4Agg" and ("ipython inputhook not present" or "not in ipython")...
Or simple hope that noone uses matplotlib in REPL mode on windows without enough knowledge to use %gui qt :-)
I personally would be fine with calling QtCore.pyqtRemoveInputHook() and emitting a warning that the inputhook has been removed. Of course only under windows if the problem is only there. Maybe someone should ask on the pyqt4 mailing list if the behavior is known.
FWIW, I also experienced this behaviour for some time on Windows with IPython (also using conda). Normally I use %matplotlib to enable interactivity, but when I forget to type that and already do a plot, the terminal indeed becomes unusable slow
same issue on a fresh Ubuntu 14.04 LTS server uptodate and in an virtualenv (may not related)
Installed via pip
note : the host is a VM I can share you a snapshot
note2: the issue is seems to be related to X11/freetype as the VM is accessed via a slow ssh connection and an X11 tunnel (ssh -X) as matplotlib/backends/backend_gtk.py need to open an X11 DISPLAY
So may there are a font resolution inserted in the REPL by matplotlib.
To reproduce it :
sudo apt-get update
sudo apt-get install python-pip python-dev python-virtualenv
virtualenv --system-site-packages ~/myenv
pip install matplotlib
python2
import numpy as np
import matplotlib.pyplot as plt
... the REPL is very slow now
Workaround, choosing your backend (not choosing gtk) fix the issue
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
Activity
WeatherGod commentedon Sep 30, 2015
Which version of matplotlib and which backend (I don't know what the
defaults are for Windows from anaconda).
On Wed, Sep 30, 2015 at 10:00 AM, Jan Schulz notifications@github.com
wrote:
jankatins commentedon Sep 30, 2015
jankatins commentedon Sep 30, 2015
Using
Aggas a backend does not have this problem (no sluggish typing afterplt.plot()), but on the other hand I also do not get a plot shown afterplt.show(). Not sure how to get a plot window with that backend?(It seems that I never really learned how to use matplotlib in another environement than the ipython notebook...)
tacaswell commentedon Sep 30, 2015
Do you have the same issue from just importing pyqt? iirc, there are some issues with the os inputhook + windows.
Do you have the same issue if you use ipython and do a
?
jankatins commentedon Oct 1, 2015
I've run
from PyQt4 import QtGuiand didn't notice a slowdown afterwards. Running%matplotlib qtin anipythonconsole (not qt, not notebook!) also didn't change anything.WeatherGod commentedon Oct 1, 2015
when you say "also didn't change anything", do you mean that it is slow
just like at the repl, or that it is normal speed, just like using Qt4
normally?
On Thu, Oct 1, 2015 at 6:08 AM, Jan Schulz notifications@github.com wrote:
jankatins commentedon Oct 1, 2015
It's normal, e.g. typing is shown instantly and c&p as well.
tacaswell commentedon Oct 1, 2015
I would just use the IPython shell then 😉. It takes care of many of the annoying details about setting up interactive mode and managing the gui event loop.
I can't reproduce this on a linux box.
jankatins commentedon Oct 1, 2015
It happens in both
pythonandipython. Unfortunately I currently don't have access to a different windows box, to test if it's specific to my box or to windows. :-(efiring commentedon Oct 1, 2015
Is the tkagg backend available? E.g. in ipython,
%matplotlib tk.I suspect your problem with qt involves a library conflict with something else installed on your machine. If it were a universal problem with Anaconda python 2.7 on Windows, I think Continuum would have been deluged with complaints by now, and I don't think I have seen this one on the anaconda mailing list.
Tillsten commentedon Oct 2, 2015
Can confirm the behavior with qt, but i think this a really old bug, which never got fixed. Something with way readline is used.
Tillsten commentedon Oct 2, 2015
I also remember that using ipython would we the fix, but this is not the case. Note that figure doesent have to be show, the slowdown happens after calling
plot.Using
%gui qtin ipython before seems to be fixing the issue.tacaswell commentedon Oct 2, 2015
Is this an old mpl bug or an old pyqt bug?
Does this happen on master branch/with the rc (which has a windows conda
build on the conda-forge channel).
On Fri, Oct 2, 2015, 10:05 Till Stensitzki notifications@github.com wrote:
Tillsten commentedon Oct 2, 2015
The mpl policies was always that if you want have interactive plots in the repl working without any haggle one has to use ipython. This is still true, as long either %gui or %matplotlib is called. As long all the input-hook experience is in the ipython team it is properly the best way, even if having the code directly in mpl would be also nice.
jankatins commentedon Oct 4, 2015
Ok, I tested it with
%matplotlib tkand it doesn't become sluggish. I will create a new test env for the newer matplotlib version and then see what happens there...2 remaining items
jankatins commentedon Oct 4, 2015
Another observation:
plt.plot(), I can paste long lines (2k words of lorem ipsum), but the python interpreter goes to 100% CPU (on one core) and it takes a while to paste the complete line (but not as slow as with plot)...plt.plot(), I can't paste long lines anymore: the interpreter has no CPU, but only 4 chars are shown (=hang?). I have to kill the interpreter (via proc explorer) to get the rest of the chars displayed (in cmd!). Shorter texts can be pasted (I tried with 230 chars), it's much slower as without the plot call but the interpreter (and cmd/...) does not use much CPU (~1% of one core).Tillsten commentedon Oct 4, 2015
You need to use Ipython and call
%matplotlib your_backendto get non sluggish behaviour. Else the eventloop and pythons inputhook won't play nice with each other.jankatins commentedon Oct 4, 2015
Using
%gui qtin ipython before theplt.plot()prevents the sluggishness (=c&p is fast afterwards). Even calling this afterplt.plot()(and observing sluggish behaviour) is restoring the fast c&p behaviour.So what this means is that using matplotlib in interactive mode on windows will result in sluggish behaviour unless setting the backend to something else than qt4 or using ipython and
%gui qt?Tillsten commentedon Oct 4, 2015
Yeah, but please note that it is not maplotlibs fault, try:
and you will see the same behaviour. IPython jumps through some hoops to circumvent that. Note that
QtCore.pyqtRemoveInputHook()fixes the sluggishness, but i don't know the downsides of it.jankatins commentedon Oct 4, 2015
With your code snippets I found ipython/ipython#481, ipython/ipython#815 and ipython/ipython#2294 which seem to implement the workarounds which make this work...
Not sure if there is any actionable item here, if matplotlib doesn't want to implement the same workaround as IPython. I think the only thing which makes sense is a warning ala "Use ipython and
%gui qt" on import if_onwindows and backend=="QT4Agg" and ("ipython inputhook not present" or "not in ipython")...Or simple hope that noone uses matplotlib in REPL mode on windows without enough knowledge to use
%gui qt:-)Tillsten commentedon Oct 4, 2015
I personally would be fine with calling
QtCore.pyqtRemoveInputHook()and emitting a warning that the inputhook has been removed. Of course only under windows if the problem is only there. Maybe someone should ask on the pyqt4 mailing list if the behavior is known.tacaswell commentedon Oct 4, 2015
The downside of removing the inputhook is that figures will no longer be 'live' unless you explicitly start the event loop (ex via
plt.pause()).jorisvandenbossche commentedon Oct 5, 2015
FWIW, I also experienced this behaviour for some time on Windows with IPython (also using conda). Normally I use
%matplotlibto enable interactivity, but when I forget to type that and already do a plot, the terminal indeed becomes unusable slowtomderuijter commentedon Nov 17, 2015
I can also confirm this issue. Using Anaconda 2.3.0 with matplotlib 1.4.3 and Python 3.4.3.
nplanel commentedon Aug 18, 2016
same issue on a fresh Ubuntu 14.04 LTS server uptodate and in an virtualenv (may not related)
Installed via pip
note : the host is a VM I can share you a snapshot
note2: the issue is seems to be related to X11/freetype as the VM is accessed via a slow ssh connection and an X11 tunnel (ssh -X) as matplotlib/backends/backend_gtk.py need to open an X11 DISPLAY
So may there are a font resolution inserted in the REPL by matplotlib.
To reproduce it :
Workaround, choosing your backend (not choosing gtk) fix the issue
efiring commentedon May 23, 2019
Closing, but if the problem is still occurring please reopen.