Qt4 on OSX

Greetings, MPL’ers.

After playing with backends quite a bit, I have found that the best one in terms of speed, robustness, and features is Qt4Agg - especially on OSX, where the MacOSX backend is buggy and many others just don’t plain work.

To my great disappointment, I have found that this backend doesn’t work on some machines anymore. As soon as a plot is created, ipython stops responding, python CPU usage goes to 100%+, and I have to kill ipython or shut the terminal. I am not the only person to experience this; a co-worker has the same problem. It didn’t use to be like this; it has started happening after an update a few months ago (I’m not sure what update, I use macports so I update in batches.)

To complicate matters, on a mac laptop (which is updated on a similar schedule as my desktop machine), I do not have this problem. Everything works flawlessly.

Has anyone else had this problem, and does anyone know of a solution?

Thanks for your help.

Details:

All software through MacPorts.

OSX 10.6.5

Ipython 0.10.1

python 2.6.6

MPL 1.0.1_2

pyqt4 4.8.3_1

Qt4-mac 4.7.1_1/4.7.2_0

I'm seeing something similar with OS X 10.6.6, python-2.7 from
macports, ipython-0.11dev, matplotlib-1.0.1. I do:

ipython --pylab
[1]: pl

and then I can't enter anything more, I have to ctrl-Z to exit, and
killall Python. If I use python instead of ipython, and have
interactive:False in my rc settings, I can execute the plot command,
but can't call show(). If interactive is True, then in python I don't
see any issues.

I'm one of the original authors of the qt4 backends, but there have
been some changes to this backend and how it handles the mainloop and
I have not been following closely enough to address the problem
without screwing up something else. If you have the luxury of
installing zeromq, pyzmq, and ipython from the master branch at
github, you can run the awesome new "ipython-qtconsole --pylab", which
appears to be running smoothly.

Darren

···

On Wed, Mar 16, 2011 at 1:59 PM, Daniel Welling <dantwelling@...287...> wrote:

Greetings, MPL'ers.
After playing with backends quite a bit, I have found that the best one in
terms of speed, robustness, and features is Qt4Agg - especially on OSX,
where the MacOSX backend is buggy and many others just don't plain work.
To my great disappointment, I have found that this backend doesn't work on
some machines anymore. As soon as a plot is created, ipython stops
responding, python CPU usage goes to 100%+, and I have to kill ipython or
shut the terminal. I am not the only person to experience this; a co-worker
has the same problem. It didn't use to be like this; it has started
happening after an update a few months ago (I'm not sure what update, I use
macports so I update in batches.)
To complicate matters, on a mac laptop (which is updated on a similar
schedule as my desktop machine), I do not have this problem. Everything
works flawlessly.
Has anyone else had this problem, and does anyone know of a solution?

Why do you think that the MacOSX backend is buggy?

–Michiel.

···

— On Wed, 3/16/11, Daniel Welling <dantwelling@…287…> wrote:

After
playing with backends quite a bit, I have found that the best one in terms of speed, robustness, and features is Qt4Agg - especially on OSX, where the MacOSX backend is buggy and many others just don’t plain work.

Hello, Michiel.

The OSX backend used to have a bug where you cannot type a name in the file name text box. Since that has been fixed, I have found a new bug: every so often, when you go to save a file, the “save” and “cancel” button stop responding, trapping the user in file saving limbo. I’ll have to play with it again to figure out what triggers this. Other than that, the OSX backend is light and quick, which is nice. When QT4 is working, however, I prefer that. Sorry I can’t give you more details; I’ll see if I can get a clearer picture.

-dw

···

On Sun, Mar 20, 2011 at 1:31 AM, Michiel de Hoon <mjldehoon@…9…> wrote:

— On Wed, 3/16/11, Daniel Welling <dantwelling@…287…> wrote:

After
playing with backends quite a bit, I have found that the best one in terms of speed, robustness, and features is Qt4Agg - especially on OSX, where the MacOSX backend is buggy and many others just don’t plain work.

Why do you think that the MacOSX backend is buggy?

–Michiel.

The OSX backend used to have a bug where you cannot type a
name in the file name text box.Since that has been fixed, …

That was not a bug in the MacOSX backend (and therefore was not fixed), but is related to how Python is installed on your system: If your Python is not a framework installation, it will not interact correctly with Apple’s windowing manager. This is due to OS X itself and is independent of the MacOSX backend.

I
have found a new bug: every so often, when you go to save a file, the “save” and “cancel” button stop responding, trapping the user in file saving limbo. I’ll have to play with it again to figure out what triggers this.
Can you check if your Python is built as a framework? If it is, MacOS.WMAvailable() should return True:

$ python
Python 2.7.1 (r271:86832, Mar 12 2011, 13:44:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import MacOS
MacOS.WMAvailable()
True

Best,
–Michiel.

···

— On Sun, 3/20/11, Daniel Welling <dantwelling@…287…> wrote:

Greetings again, Michiel. Please excuse my slow response time…

First, thanks for explaining the Framework stuff; it clarifies situation. I’ll be sure to never blame the OSX backend where it is not warranted!

Unfortunately (in terms of easy explanations):

In [3]: MacOS.WMAvailable()

Out[3]: True

crap.

Fortunately, I’ve been able to nail down the problem:

bash-3.2$ ipython

Python 2.6.6 (r266:84292, Jan 18 2011, 14:07:55)

Type “copyright”, “credits” or “license” for more information.

IPython 0.10.1 – An enhanced Interactive Python.

? → Introduction and overview of IPython’s features.

%quickref → Quick reference.

help → Python’s own help system.

object? → Details about ‘object’. ?object also works, ?? prints more.

In [2]: import matplotlib.pyplot as plt

In [3]: plt.plot([0,1])

Out[3]: [<matplotlib.lines.Line2D object at 0x118c6be90>]

In [4]: plt.show()

(Here, saving the plot works like normal.)

In [5]: plt.ion()

In [6]: plt.plot([0,1])

Out[6]: [<matplotlib.lines.Line2D object at 0x118c8bc90>]

(Now, when trying to save the plot, the “save” and “cancel” buttons no longer respond. I must kill python from another terminal.)

So that’s the situation with OSX. It’s something that comes up frequently enough (typically a quick plot turns into a more thorough customization followed by the lockup) that TK becomes a more viable option for me though OSX is faster and has better file navigation features. Again, if QT4 was working, that is certainly my weapon of choice…

···

On Mon, Mar 21, 2011 at 7:14 AM, Michiel de Hoon <mjldehoon@…9…> wrote:

— On Sun, 3/20/11, Daniel Welling <dantwelling@…287…> wrote:

The OSX backend used to have a bug where you cannot type a

name in the file name text box.Since that has been fixed, …

That was not a bug in the MacOSX backend (and therefore was not fixed), but is related to how Python is installed on your system: If your Python is not a framework installation, it will not interact correctly with Apple’s windowing manager. This is due to OS X itself and is independent of the MacOSX backend.

I
have found a new bug: every so often, when you go to save a file, the “save” and “cancel” button stop responding, trapping the user in file saving limbo. I’ll have to play with it again to figure out what triggers this.

Can you check if your Python is built as a framework? If it is, MacOS.WMAvailable() should return True:

$ python
Python 2.7.1 (r271:86832, Mar 12 2011, 13:44:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import MacOS
MacOS.WMAvailable()
True

Best,

–Michiel.

OK, thanks. I got the same behavior using Python (instead of ipython).
Non-interactive usage has not yet been implemented in the MacOSX backend. We should be able to fix the bug that you found when implementing interactive/non-interactive usage for the MacOSX backend.
Thanks,
–Michiel.

···

— On Wed, 3/23/11, Daniel Welling <dantwelling@…287…> wrote:

From: Daniel Welling <dantwelling@…287…>
Subject: Re: [Matplotlib-users] Qt4 on OSX
To: “Michiel de Hoon” <mjldehoon@…9…>
Cc: matplotlib-users@lists.sourceforge.net
Date: Wednesday, March 23, 2011, 12:27 PM

Greetings again, Michiel. Please excuse my slow response time…

First,
thanks for explaining the Framework stuff; it clarifies situation. I’ll be sure to never blame the OSX backend where it is not warranted!

Unfortunately (in terms of easy explanations):

In [3]: MacOS.WMAvailable()

Out[3]: True

crap.

Fortunately, I’ve been able to nail down the problem:

bash-3.2$ ipython

Python 2.6.6 (r266:84292, Jan 18 2011, 14:07:55)

Type “copyright”, “credits” or “license” for more information.

IPython 0.10.1 – An enhanced Interactive Python.

? → Introduction and overview of IPython’s features.

%quickref → Quick reference.

help → Python’s own help system.

object? → Details about ‘object’. ?object also works, ?? prints more.

In [2]: import matplotlib.pyplot as plt

In [3]: plt.plot([0,1])

Out[3]: [<matplotlib.lines.Line2D object at 0x118c6be90>]

In [4]: plt.show()

(Here, saving the plot works like normal.)

In [5]: plt.ion()

In [6]: plt.plot([0,1])

Out[6]: [<matplotlib.lines.Line2D object at 0x118c8bc90>]

(Now, when trying to save the plot, the “save” and “cancel” buttons no longer respond. I must kill python from another terminal.)

So that’s the situation with OSX. It’s something that comes up frequently enough (typically a quick plot turns into a more thorough customization followed by the lockup) that TK becomes a more viable option for me though OSX is faster and has better file navigation features. Again, if QT4 was working, that is certainly my weapon of choice…

On Mon, Mar 21, 2011 at 7:14 AM, Michiel de Hoon <mjldehoon@…9…> wrote:

— On Sun, 3/20/11, Daniel Welling <dantwelling@…287…> wrote:

The OSX backend used to have a bug where you cannot type a

name in the file name text box.Since that has been fixed, …

That was not a bug in the MacOSX backend (and therefore was not fixed), but is related to how Python is installed on your system: If your Python is not a framework installation, it will not interact correctly with Apple’s windowing manager. This is due to OS X itself and is independent of the MacOSX backend.

I
have found a new bug: every so often, when you go to save a file, the “save” and “cancel” button stop responding, trapping the user in file saving limbo. I’ll have to play with it again to figure out what triggers this.

Can you check if your Python is built as a framework? If it is, MacOS.WMAvailable() should return True:

$ python
Python 2.7.1 (r271:86832, Mar 12 2011, 13:44:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import MacOS
MacOS.WMAvailable()
True

Best,

–Michiel.

Thanks for your help, Michiel. Two follow up points, one concerning the OSX backend and one concerning the QT4 backend:

  1. A colleague can reproduce the OSX problem we have talked about, but has never run into it before. We have identical installs of python/matplotlib/etc through MacPorts, however his OSX plots pop up automatically without turning interactive plotting on (pyplot.ion()). I did not have this behavior; show() was required to bring up a plot up until ion() was called. A fresh install (see item 2) has “fixed” this behavior on my machine so that our two installs now behave identically.

  2. With an understanding of the importance of a +framework install when using Python/MPL, I wiped my QT4 and pyqt4 installs (again, through MacPorts) and reinstalled. I also reinstalled MPL. Because I have been using all of them for some time, I had many old versions installed but not activated in MacPorts. I removed every old version for all of the programs listed above and started from scratch. I used the +framework variant (also, +quartz). Everything seems to work smoothly now. I’m not sure why; was it the fresh install? was it the +framework variant? This fresh install also seemed to change the MacOSX backend behavior, however I have done nothing different with how I installed MPL.

Hopefully, this info is useful to someone down the line. Thanks again to Michiel for his clarifications and help with the OSX backend; it is one of the better backends if you are on a Mac!

-dw

···

On Wed, Mar 23, 2011 at 2:34 PM, Michiel de Hoon <mjldehoon@…9…> wrote:

OK, thanks. I got the same behavior using Python (instead of ipython).
Non-interactive usage has not yet been implemented in the MacOSX backend. We should be able to fix the bug that you found when implementing interactive/non-interactive usage for the MacOSX backend.
Thanks,
–Michiel.
— On Wed, 3/23/11, Daniel Welling <dantwelling@…287…> wrote:

From: Daniel Welling <dantwelling@…287…>
Subject: Re: [Matplotlib-users] Qt4 on OSX
To: “Michiel de Hoon” <mjldehoon@…9…>

Cc: matplotlib-users@lists.sourceforge.net
Date: Wednesday, March 23, 2011, 12:27 PM

Greetings again, Michiel. Please excuse my slow response time…

First,
thanks for explaining the Framework stuff; it clarifies situation. I’ll be sure to never blame the OSX backend where it is not warranted!

Unfortunately (in terms of easy explanations):

In [3]: MacOS.WMAvailable()

Out[3]: True

crap.

Fortunately, I’ve been able to nail down the problem:

bash-3.2$ ipython

Python 2.6.6 (r266:84292, Jan 18 2011, 14:07:55)

Type “copyright”, “credits” or “license” for more information.

IPython 0.10.1 – An enhanced Interactive Python.

? → Introduction and overview of IPython’s features.

%quickref → Quick reference.

help → Python’s own help system.

object? → Details about ‘object’. ?object also works, ?? prints more.

In [2]: import matplotlib.pyplot as plt

In [3]: plt.plot([0,1])

Out[3]: [<matplotlib.lines.Line2D object at 0x118c6be90>]

In [4]: plt.show()

(Here, saving the plot works like normal.)

In [5]: plt.ion()

In [6]: plt.plot([0,1])

Out[6]: [<matplotlib.lines.Line2D object at 0x118c8bc90>]

(Now, when trying to save the plot, the “save” and “cancel” buttons no longer respond. I must kill python from another terminal.)

So that’s the situation with OSX. It’s something that comes up frequently enough (typically a quick plot turns into a more thorough customization followed by the lockup) that TK becomes a more viable option for me though OSX is faster and has better file navigation features. Again, if QT4 was working, that is certainly my weapon of choice…

On Mon, Mar 21, 2011 at 7:14 AM, Michiel de Hoon <mjldehoon@…9…> wrote:

— On Sun, 3/20/11, Daniel Welling <dantwelling@…287…> wrote:

The OSX backend used to have a bug where you cannot type a

name in the file name text box.Since that has been fixed, …

That was not a bug in the MacOSX backend (and therefore was not fixed), but is related to how Python is installed on your system: If your Python is not a framework installation, it will not interact correctly with Apple’s windowing manager. This is due to OS X itself and is independent of the MacOSX backend.

I
have found a new bug: every so often, when you go to save a file, the “save” and “cancel” button stop responding, trapping the user in file saving limbo. I’ll have to play with it again to figure out what triggers this.

Can you check if your Python is built as a framework? If it is, MacOS.WMAvailable() should return True:

$ python
Python 2.7.1 (r271:86832, Mar 12 2011, 13:44:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

import MacOS
MacOS.WMAvailable()
True

Best,

–Michiel.