RuntimeError: could not open display on headless machines
dfranke76 opened this issue · 3 comments
Connected to a Linux host via ssh, without X forwarding:
$ denss.py
Traceback (most recent call last):
File "/apps/prod/denss/latest/bin/denss.py", line 30, in
import saxstats.denssopts as dopts
File "/apps/prod/denss/latest/lib/python2.7/site-packages/saxstats/denssopts.py", line 9, in
import matplotlib.pyplot as plt
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 97, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/init.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 13, in
import gtk; gdk = gtk.gdk
File "/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/init.py", line 64, in
_init()
File "/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/init.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display
It shouldn't try to open anything this early, maybe? I actually tried to get the "--help" output and couldn't. Eventually commented out all attempts to import matplotlib (once in denss.py, once in denssopts.py), , then this disappeared.
That's a good point. I was searching for matplotlib, which apparently it found on your headless machine, but then it couldn't actually import it, so it threw the error. I've just changed up the logic throughout the scripts to simply try to import matplotlib, then set plotting to false if that fails. I just pushed those changes. hopefully that works for you (I can't test that myself.)
Updated. No more errors on import after the latest changes. Have not tested if it would still create any plots otherwise.
Okay thanks for testing. I'll close the issue and then if you do run into new errors, I can reopen. Thanks.