4

Often times, I ssh into another computer to do python work. While I'm coding, I like to have an ipython shell open for quick testing. For some reason, I cannot get matplotlib to open figures. Here is an example:

[mwoods@linux_box ~]$ ssh -X me@mac_machine
Password:
Last login: Fri Dec 15 13:03:37 2017
mwoods:~ /path/to/ipython
Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38)
Type ‘copyright’, ‘credit’ or ‘license’ for more information
IPython 6.1.0 — An enhanced Interactive Python. Type ‘?’ for help.

In [1]: import matplotlib as mpl

In [2]: mpl.use('Agg')

In [3]: import matplotlib.pyplot as plt

In [4]: import numpy as np

In [5]: plt.ion()

In [6]: plt.imshow(np.random.rand(8, 8))
Out[6]: <matplotlib.image.AxesImage at hex_number>

In [7]: 

No plot opens. As shown, I start from a linux box and ssh into a Macintosh (I have admin privileges on the mac). The mac runs on macOS Sierra (10.12.6) and has Anaconda version 5.0.1 installed. Other X11 forwarding commands (e.g. xpdf, display) work over the same ssh connection, so I don't think it has to do with the ssh_config or sshd_config files on either machine. Could someone please help?

  • 2
    This is an interesting problem. You might need to migrate it to Super User, but it's a good question either way. – cwallenpoole Dec 18 '17 at 19:23
  • Can you tell us what backend is being used? That might need some help to be forwarded through the connection. stackoverflow.com/q/3580027/2449192 – darthbith Dec 18 '17 at 21:16
  • @darthbith I edited the post to show a backend. The default is MacOSX, but that doesn't work. I tried Agg (as shown above), but that also doesn't work. I then tried GTK and GTKAgg, but I don't have pygtk. I tried "conda install -c mw gtk2", but I get an HTTP error. It tells me to keep trying, but I'm not having any luck with it. – mwoods Dec 18 '17 at 22:47
0

Maybe give the -Y flag to ssh a try in place of -X. See documentation of the ForwardX11Trusted option for what might be going on.

  • I should have mentioned above that I have tried this. Both -X and -Y flags don't open matplotlib figures. Although, as mentioned in the original post, both flags work for programs like xpdf and ImageMagick. – mwoods Jan 2 '18 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.