matplotlib running on OzStar
When running on OzStar through slurm submission (not through the command line on the front node) there is an issue with trying to create plots.
Traceback (most recent call last):
File "basic_tutorial.py", line 35, in <module>
sampling_frequency=sampling_frequency, outdir=outdir) for name in ['H1', 'L1', 'V1']]
File "/home/plasky/.local/lib/python2.7/site-packages/tupak/detector.py", line 691, in get_interferometer_with_fake_noise_and_injection
fig, ax = plt.subplots()
File "/home/plasky/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 1198, in subplots
fig = figure(**fig_kw)
File "/home/plasky/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 548, in figure
**kwargs)
File "/home/plasky/.local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 161, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/home/plasky/.local/lib/python2.7/site-packages/matplotlib/backends/_backend_tk.py", line 1044, in new_figure_manager_given_figure
window = Tk.Tk(className="matplotlib")
File "/apps/skylake/software/compiler/gcc/6.4.0/python/2.7.14/lib/python2.7/lib-tk/Tkinter.py", line 1819, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
One fix to this is to add the following two lines of code to the top of the python script that gets submitted (in this case, basic_tutorial.py
import matplotlib
matplotlib.use('Agg')
This fix is clearly not satisfactory as it needs to be done everytime. Is there a way to get this working by default?