Migrated from my local machine to a remote server a data analysis that plots data using Python’s matplotlib and saves the plots to PNGs. Running the analysis turned up an unexpected error that ends by noting:

no display name and no $DISPLAY environment variable

Bummer. A quick search turned up more documentation on this from both the official matplotlib documentation on using matplotlib in a webapp and generating PNGs in matplotlib when DISPLAY is not defined.

The two typical solutions are to explicitly set a backend in the Python code (this must be done before any other matplotlib imports):

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

or set the backend using the matplotlibrc file.

Trackback

no comment untill now

Sorry, comments closed.