Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one remotely access an IPython Notebook without using inline plotting?

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.

like image 713
user1522298 Avatar asked Jul 13 '12 00:07

user1522298


1 Answers

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!).

like image 188
drevicko Avatar answered Nov 02 '22 09:11

drevicko