My question is related to a python error, but I suspect that it is more a Linux question than a python one. Thus I post it first here.
I am running a python script which does a calculation and then produces a plot and saves it in a PDF file. The script runs through on my local machine (Mac OS), but when I run it on the cluster of my workplace (Linux) it crashes when trying to produce the plot on the PDF with the following error:
Traceback (most recent call last):
File "<my_python_script>.py", line 496, in <module>
if __name__ == "__main__": main()
File "<my_python_script>.py", line 487, in main
plot(model, obsdata, popt, pdf_file)
File "<my_python_script>.py", line 455, in plot
plt.figure(figsize=(11.69, 8.27))
File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 89, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Here I substituted <my_python_script> to abbreviate the unimportant path and name of my script.
It may or may not be related to the problem, but I should also mention, that the script is not run manually from the command line, but submitted to a slurm queue.
Unfortunately I really don't know enough about Unix/Linux to make this work on the cluster. Since it runs on through on my local machine, I suspect that it must have to do something with the settings on the cluster, and in particular with the settings related to my used. The latter I know because I have colleagues for which the script also runs on the very same cluster.
Does anyone have an idea?