Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matplotlib macosx windows don't respond in qtconsole #640

Closed
claumann opened this issue Jul 29, 2011 · 15 comments
Closed

matplotlib macosx windows don't respond in qtconsole #640

claumann opened this issue Jul 29, 2011 · 15 comments

Comments

@claumann
Copy link
Contributor

Running 0.11 rc1 and rc4, I can use the osx backend to plot (in new figure windows) but the windows do not respond to mouse clicks or any gui events. Is this my fault or something to be fixed?

@minrk
Copy link
Member

minrk commented Jul 29, 2011

Are you using --pylab or --pylab=osx? The OSX native backend eventloop doesn't get polled when run in a non-interactive process (as opposed to in a Terminal), so you must use '--pylab' mode for it to work.

@claumann
Copy link
Contributor Author

Using:

ipython qtconsole --pylab

Then in the qt console:

x = r_[0:2*pi:100j]
y = sin(x)
plot(x,y)

A new figure appears in an osx window (using osx backend) but no events work on it (can't close, resize, use bottom toolbar, etc).

@minrk
Copy link
Member

minrk commented Jul 29, 2011

hm, what version of matplotlib?

I'm using master, and it's perfectly responsive.

@claumann
Copy link
Contributor Author

I'm using enthought's latest distribution which has MPL 1.0.1 along with ipython 0.11rc1 (which I updated to rc4). I also can't use pylab=qt because it complains I don't have PyQt4.

@minrk
Copy link
Member

minrk commented Jul 29, 2011

The pylab=qt was a typo, should have been pylab=osx.

I am using matplotlib master, but I will try to check out 1.0.1, and
see if it's different.

@claumann
Copy link
Contributor Author

claumann commented Aug 1, 2011

I upgraded to 0.11, still using standard Enthought install otherwise and still the osx backend is not responding.

@claumann
Copy link
Contributor Author

claumann commented Aug 1, 2011

And now I've just compiled the master branch of matplotlib (1.1.0) and it still doesn't work. Doesn't seem to be an MPL thing. BTW, i'm on Lion. Any more debugging I can try?

@minrk
Copy link
Member

minrk commented Aug 1, 2011

Hm, this is troubling. I, too, am running Lion and the OSX backend with the qtconsole with some regularity. There's some chance that it's EPD that's causing the trouble, but I don't see how.

Can you post some of the startup output of ipython qtconsole --debug --pylab (up to, but not including the first huge message)?

I think this behavior is exactly what happens when you use the OSX backend without launching IPython in pylab-mode, but I'm not sure how that would be happening.

@claumann
Copy link
Contributor Author

claumann commented Aug 1, 2011

How's this?

blackbear:~$ ipython qtconsole --debug --pylab
[IPythonQtConsoleApp] Config changed:
[IPythonQtConsoleApp] {'Application': {'log_level': 10}, 'IPKernelApp': {'pylab': 'auto'}}
[IPythonQtConsoleApp] Using existing profile dir: u'/Users/claumann/.ipython/profile_default'
[IPythonQtConsoleApp] Attempting to load config file: ipython_config.py
[IPythonQtConsoleApp] Attempting to load config file: ipython_qtconsole_config.py
[IPKernelApp] Config changed:
[IPKernelApp] {'Application': {'log_level': 10}, 'KernelApp': {'stdin_port': 49961, 'hb_port': 49962, 'parent': 1, 'ip': u'127.0.0.1', 'shell_port': 49959, 'parent_appname': 'ipython-qtconsole', 'iopub_port': 49960}, 'IPKernelApp': {'pylab': 'auto'}}
[IPKernelApp] Using existing profile dir: u'/Users/claumann/.ipython/profile_default'
[IPKernelApp] Attempting to load config file: ipython_config.py
[IPKernelApp] Attempting to load config file: ipython_qtconsole_config.py
[IPKernelApp] Starting the kernel at pid: 24307
[IPKernelApp] shell XREP Channel on port: 49959
[IPKernelApp] iopub PUB Channel on port: 49960
[IPKernelApp] stdin XREQ Channel on port: 49961
[IPKernelApp] Heartbeat REP Channel on port: 49962
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing --shell=49959 --iopub=49960 --stdin=49961 --hb=49962
[IPKernelApp]
* MESSAGE TYPE:execute_request*
[IPKernelApp] Content: {u'user_variables': [], u'code': u'', u'user_expressions': {}, u'silent': True}
--->

[IPKernelApp] {'parent_header': {u'date': datetime.datetime(2011, 8, 1, 14, 51, 40, 647485), u'username': u'claumann', u'session': u'08e5b0cf-676f-4117-971d-ba1d617e4126', u'msg_id': u'95cdc6d3-55f2-491a-b60f-059da79bfdea', u'msg_type': u'execute_request'}, 'msg_type': u'execute_reply', 'msg_id': '52b14acd-6e15-47f9-b13f-c62ff64d0718', 'content': {u'status': u'ok', 'execution_count': 0, u'payload': [], u'user_expressions': {}, u'user_variables': {}}, 'header': {'date': datetime.datetime(2011, 8, 1, 14, 51, 41, 850532), 'username': u'kernel', 'session': '0cf962ba-777b-4bc0-be61-e8d3c407bb94', 'msg_id': '52b14acd-6e15-47f9-b13f-c62ff64d0718', 'msg_type': u'execute_reply'}, 'tracker': None}
[IPKernelApp]
* MESSAGE TYPE:history_request*
[IPKernelApp] Content: {u'hist_access_type': u'tail', u'output': False, u'n': 1000, u'raw': True}
--->

Next line is absolutely enormous.

On Aug 1, 2011, at 1:28 PM, minrk wrote:

Hm, this is troubling. I, too, am running Lion and the OSX backend with the qtconsole with some regularity. There's some chance that it's EPD that's causing the trouble, but I don't see how.

Can you post some of the startup output of ipython qtconsole --debug --pylab (up to, but not including the first huge message)?

I think this behavior is exactly what happens when you use the OSX backend without launching IPython in pylab-mode, but I'm not sure how that would be happening.

Reply to this email directly or view it on GitHub:
#640 (comment)

@gcalmettes
Copy link

I have the same issue.

  • Launching ipython (without qtconsole) works fine (by using the Agg or osx as Backend for matplotlib).
  • Launching ipython qtconsole works fine only with --pylab=inline or --pylab=qt tags. If the --pylab=osx is specified, when I want to plot, a new matplotlib windows pops up but doesn't respond (whatever the backend option defined).

I'm running Leopard (10.5) on a ppc machine. What system are you running claumann?
Could be a problem with 10.5 since minrk doesn't have any problem with Lion.

edit: choosing backend = TkAgg or Qt4Agg in the matplotlibrc file solved the problem, ipython qtconsole works fine after that

@claumann
Copy link
Contributor Author

I'm running on Lion with a recent (one year old) intel macbook pro. Basic python world provided by Enthought 7.1-1 (64-bit).

I just updated to the master ipython from github and it still doesn't work with the osx backend. Haven't been able to use any others -- I don't have Qt4 or wxPython installed and using --pylab=tk crashes the kernel after drawing the window for the plot. (with the error message alloc: invalid block: 0x105d3efc0: 47 0)

@claumann
Copy link
Contributor Author

Also, using the html notebook with --pylab=osx backend has the exact same problem of non-responsive plotting windows.

@minrk
Copy link
Member

minrk commented Sep 17, 2011

@claumann it makes sense that the behavior is the same between the qtconsole and notebook, as they use the same kernel code (where all the real execution happens).

I typically use matplotlib trunk, which is generally better behaved (much less crashy with the osx backend), but I just installed the 1.0.1 egg from sourceforge, and it still behaves just fine, so I'm baffled. At some point, I will try installing EPD, and see if it behaves any differently. You might try getting the eggs from the scipy superpack, and see if they don't work better.

So: System Python (2.7 on Lion and 2.6 on SL) + git numpy + matplotlib (1.0.1 or trunk) definitely work fine here.

@minrk
Copy link
Member

minrk commented Sep 19, 2011

I've looked into this a bit, and it does seem to be unique to EPD. It at least does not affect System Python, and shouldn't affect any official Python.org distros, but it will affect any Python that is built against non-native libtk (could include macports).

I had forgotten that selecting the OSX backend uses the Tk version of the kernel in order to get the zmq polling integrated with the backend eventloop. Using Tk works fine with the system Python because the system Tk is native Cocoa, so the CFRunLoop (the native eventloop) that the osx backend hooks into is that of the Tk app, and events are processed properly. However, EPD's Tk is bizarrely linked against X11 instead of native libraries, so it doesn't advance the CFRunLoop. This explains why the behavior in EPD is the same as if the backend eventloop is not hooked up - it isn't.

I certainly don't blame EPD for shipping their own Tk - the system one is notoriously a mess - but that is the root cause of this issue.

So, essentially we need to figure out a different way to get the CFRunLoop going without using Tk, since Tk can't be assumed to be using the native toolkit.

Any matplotlib and/or Mac folks have clever ideas for how to integrate with the native eventloop when stdin doesn't exist?

minrk added a commit to minrk/ipython that referenced this issue Sep 20, 2011
via matplotlib.backend_macosx.TimerMac, rather than Tk

Fallback on Tk if matplotlib is < 1.1.0, which introduces the necessary Timer. This means that it still won't work on current EPD, which has X11-linked libtk and matplotlib 1.0.1,
but at least it will display a warning explaining why.

also remove caveat in docs that qtconsole doesn't work with native MacOSX, since it does on normal (non-EPD) installs.

So this will work in more places, but still not in most common failure case (stock EPD) described in ipython#640.
@minrk
Copy link
Member

minrk commented Oct 14, 2011

closed by #809. There is still no way to run ipython --pylab osx on matplotlib 1.0.1 with non-native tk, but it works with current dev matplotlib (1.1), which is the best we can do, I think.

@minrk minrk closed this as completed Oct 14, 2011
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
via matplotlib.backend_macosx.TimerMac, rather than Tk

Fallback on Tk if matplotlib is < 1.1.0, which introduces the necessary Timer. This means that it still won't work on current EPD, which has X11-linked libtk and matplotlib 1.0.1,
but at least it will display a warning explaining why.

also remove caveat in docs that qtconsole doesn't work with native MacOSX, since it does on normal (non-EPD) installs.

So this will work in more places, but still not in most common failure case (stock EPD) described in ipython#640.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants