Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Headless MatplotLib / Pyplot
    primarykey
    data
    text
    <p>I'm trying to make my data analysis and reports less <em>eye stabbing</em> and more graphical with automatically generated graph-files, and to do this I've been playing with matplotlib/pyplot/pylab. Works brilliantly, but when I try to run it on a headless server...</p> <pre><code>tkinter.TclError: no display name and no $DISPLAY environment variable </code></pre> <p>For this application I only use PyLab, but after a little google, I added the below to before the pylab import:</p> <pre><code>import matplotlib matplotlib.use("Agg") </code></pre> <p>Which should have changed the backend, but to no effect. </p> <p>Any ideas what I'm doing wrong? </p> <p>The remote machine does have X-forwarding capabilities, but since this application shouldn't NEED to display anything, I believe the usual ssh -X hack is overkill.</p> <p><strong>Examples:Fiendish Deception</strong></p> <p>Example <em>working</em> code on same machine</p> <pre><code>import matplotlib matplotlib.use("Agg") import numpy as np import pylab as pl xvals=np.arange(100) yvals=np.cumsum(np.random.random(100)) yvals[-10:]=0 yvals=np.log(yvals) pl.close() pl.plot(xvals,yvals) pl.xlabel("X") pl.ylabel("Y") pl.title("Title") pl.savefig("testgraph.png") </code></pre> <p><em>Non-working</em> real code</p> <pre><code>import matplotlib matplotlib.use("Agg") import numpy as np import pylab as pl import utility as util import os ... non graph stuff... def graph_p(self): pl.close() channels=range(self.p.shape[0]) for line in range(self.p.shape[1]): yvals=np.ma.masked_invalid(map(util.watts_to_dbmhz,self.p[:,line])) pl.plot(channels,yvals) #Error says it occurs here pl.xlabel("Subchannel Index") pl.ylabel("Power (dbmhz)") pl.title("Plot of per-tone power assignments for %d lines"%self.p.shape[1]) pl.savefig(self.dest+self.scenario+'-power.png') </code></pre> <p>Nothing else touches pyplot.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload