_tkinter.TclError: no display name and no $DISPLAY environment variable

Matplotlib chooses Xwindows backend by default. You need to set matplotlib to not use the Xwindows backend. Add this code to the start of your script (before importing pyplot) and try again: Or add to .config/matplotlib/matplotlibrc line backend: Agg to use non-interactive backend. Or when connect to server use ssh -X remoteMachine command to use … Read more

_tkinter.TclError: no display name and no $DISPLAY environment variable

Matplotlib chooses Xwindows backend by default. You need to set matplotlib to not use the Xwindows backend. Add this code to the start of your script (before importing pyplot) and try again: Or add to .config/matplotlib/matplotlibrc line backend: Agg to use non-interactive backend. Or when connect to server use ssh -X remoteMachine command to use … Read more

Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?

Even though they are equivalent, I think there is a pretty good argument that the second form import matplotlib.pyplot as plt is objectively more readable: It is generally customary to use import matplotlib.pyplot as plt and suggested in the matplotlib documentation (see http://matplotlib.org/users/pyplot_tutorial.html etc…) so this will be more familiar to most readers. import matplotlib.pyplot … Read more