Runtimeerror: Invalid Display Variable

RuntimeError: Invalid DISPLAY variable

You must declare matplotlib.use('agg') before import pylab as plt.

Reference

docker/matplotlib: RuntimeError: Invalid DISPLAY variable

The reason is that I import seaborn before I import matplotlib. This caused matplotlib not running in the right place.

matplotlib pyplot Invalid DISPLAY variable

When running a jupyter notebook on a server, the server may not even be able to display the plot. The usual solution would be to use a non-interactive backend. In case of a jupyter notebook this would be done by adding

%matplotlib inline

at the top of the notebook, such that graphics are shown as png images.

plotting without display: correct use of matplotlib.use()

You need to

import matplotlib
matplotlib.use('Agg')

on a fresh kernel, especially if you are using ipython, before importing matplotlib.pyplot

I'd be curious, and happy, to know if there are ways to clear/flush the ipython kernel, without having to restart it; so far, my quest has not been successful.



Related Topics



Leave a reply



Submit