Linux – Running Pyplot over Putty ssh from windows machine to linux

linuxputtypythonssh

I am running python code on a linux machine through a putty ssh from a windows machine.

I need to run the following commands:

dataframe.plot()
matplotlib.pylot.savfig("some figure.png")

Nothing actually gets displayed, but the python code apparently checks to see that the display variable is set. Anyhow, the display variable is invalid and has nowhere to go.

I did what I usually do when ssh'ing from a linux box:

export DISPLAY=:0.0

But then I ran into an issue with the X-server. So I enabled X11 forwarding through putty.

Then, I ran into the issue that there is no X-server on Windows…

Is there a way I can just bypass this and get the data to save?

(or I guess set up an X-server and redirect the display)
(Have installed Xming, and am running it…but that is as far as I've gotten…I still haven't managed to export the display to the X server…)

Best Answer

As described by this question and this question, you can configure pyplot to not try to use the display:

import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
Related Question