farmir
farmir

Reputation: 1439

ipython kernel with remote display

I use an ipython kernel on a remote machine via:

user@remote_machine$ ipython kernel
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-24970.json

and then through manual ssh tunneling (see here) connect a qtconsole on my local machine to it:

user@local_machine$ for port in $(cat kernel-24970.json | grep '_port' | grep -o '[0-9]\+'); do ssh remote_machine -Y -f -N -L $port:127.0.0.1:$port; done
user@local_machine$ ipython qtconsole --existing kernel-24970.json

This works fine. However, to visualize my data while debugging, i want to use matplotlib.pyplot. Although I have enabled X11 forwarding on my ssh tunnel (through -Y), when I try plotting something, I get the following error:

TclError: no display name and no $DISPLAY environment variable

as if X11 forwarding does not have any effect.

Furthermore, once when I had access to the remote machine, I started the remote kernel with:

user@remote_machine$ ipython qtconsole

and repeated the same process from my local machine. This time, I wasn't getting any errors. But the figures were being plotted on the remote machine instead of my local machine.

So, does anyone know if it's possible to connect to a remote ipython kernel, and display plots locally? (please note that inline mode works, and shows the plots in the local qtconsole, but that's not useful for me as I frequently need to zoom in).

Upvotes: 0

Views: 1126

Answers (1)

0 _
0 _

Reputation: 11464

A simpler and more robust approach is to run ipython remotely as you did, and instead of trying to plot the figures remotely, instead save them remotely. At the same time mount the remote directory using sftp, and open it in your local file browser.

Make sure to refresh your directory view in case the images that were saved remotely are not visible (otherwise it can take some time for this to happen). One simple way for refreshing the remote directory's view is noted here.

Upvotes: 0

Related Questions