6
votes

I'd like to connect to an IPython notebook on a remote computer (either via an ssh-tunnel or via https) and have the ipython notebook open a matplotlib plot in a new window (versus 'inline').

Is this possible?

When I attempt to plot without the 'inline' backend, the notebook kernal reports ' : cannot connect to X server ', and crashes.

X11 server is running on the client computer, and I enabled X11 forwarding using the -Y option when creating the ssh-tunnel.

Thanks for any advice.

1
You need to enable X11 forwarding on the remote computer too (with sshd options). - n. 1.8e9-where's-my-share m.
Thanks, but I believe this option is enabled, i.e I can use X11 to open windows for emacs,gimp,etc... but somehow the ipython kernel running notebook is unable to. - user1522298
Firstly, you said "using the -Y option" : it should be -X. Now, I've been able to do this from one of my Ubuntu computers (though it was a little unstable.. tended to snap my adsl connection). From my other box (with direct internet), the ipython kernels crash with "cannot connect to X server" if I try to show() a plot. As yet, I've not worked out why... - drevicko

1 Answers

5
votes

Yes, it is, at least via ssh port tunneling.

(NOTE: the examples blow were done on Ubuntu 12.04, but the same principle should work for other platforms)

I was having similar problems and found that if I run the IPython notebook from within the port- and X-forwarding ssh session (ie: the one that sets up the port and X forwarding), it works. Clunky and annoying, but it works. For example:

at-home:~$ ssh -X -L 8889:localhost:8888 my.server
... login message from my.server
my.server:$ cd /folder/containing/my/notebooks
my.server:$ ipython notebook
[NotebookApp] .... lots of info about the IPython notebook server including
[NotebookApp] The IPython notebook is running at 'http://127.0.0.1:8888/'

Note that I've forwarded port 8889 - this means I use http://localhost:8889/ in a browser on my at-home machine. For me, this works nicely with the Qt4Agg backend.

I suspect that it will also work for accessing notebooks over https if you run the IPython notebook server in this way (ie: from within an ssh -X session). Note that the plots will appear on the machine from which the X session was forwarded. If someone runs a notebook in a browser on another machine, this could be a bit strange!

It may be possible to tell a running IPython notebook server how to find the X server forwarded by some new ssh session, but I'm not sure how (knowledgeable edits welcome!).