heisenberg
heisenberg

Reputation: 47

matplotlib pyplot Invalid DISPLAY variable

While importing and attempting the following:

import matplotlib
from matplotlib import pyplot as plt


plt.plot([1,2,3],[1,4,9])
plt.show()

I get the following error. How do I fix? I am running Python 2.7, and notebook version 4.1.0. Thank you.

RuntimeError: Invalid DISPLAY variable

Upvotes: 1

Views: 2713

Answers (1)

ImportanceOfBeingErnest
ImportanceOfBeingErnest

Reputation: 339670

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.

Upvotes: 3

Related Questions