[Matplotlib-users] matplotlib compilation and running issues
Jeff Blackburne
jblackburne at gmail.com
Thu Sep 17 20:20:01 CEST 2015
Hi Jason,
$DISPLAY should normally look like HOSTNAME:X where HOSTNAME is your local
machine's hostname and X is some number. That's assuming you have a
graphical display running. Matplotlib is trying to start up one of its
interactive backends, but cannot because your $DISPLAY is blank. You can
fix this by setting $DISPLAY to its proper value, or by switching backends
to a non-interactive backend like 'agg', which will let you save figures to
disk.
I can't help you with the former, except to say that if you are connecting
to a remote machine using ssh, you can try forwarding your local display to
the remote machine using ssh -X.
To do the latter, insert these 2 lines before your code:
import matplotlib as mpl
mpl.use('agg')
-Jeff
On Thu, Sep 17, 2015 at 11:04 AM, Jason Snyder <jmssnyder at ucdavis.edu>
wrote:
> To who it may concern,
>
> I installed matplotlib on my computer and tried to run a program with the
> code below:
>
> import numpy as np
> import matplotlib.pyplot as plt
>
>
> x = np.linspace(0, 10)
> line, = plt.plot(x, np.sin(x), '--', linewidth=2)
>
> When I ran the program I could the below error output:
>
> [vrsops at am-linux-212 cpcharts]$ python line_demo_dash_control.py
> Traceback (most recent call last):
> File "line_demo_dash_control.py", line 12, in <module>
> line, = plt.plot(x, np.sin(x), '--', linewidth=2)
> File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line
> 3092, in plot
> ax = gca()
> File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line
> 828, in gca
> ax = gcf().gca(**kwargs)
> File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line
> 462, in gcf
> return figure()
> File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line
> 435, in figure
> **kwargs)
> File
> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py",
> line 47, in new_figure_manager
> return new_figure_manager_given_figure(num, thisFig)
> File
> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py",
> line 54, in new_figure_manager_given_figure
> canvas = FigureCanvasQTAgg(figure)
> File
> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt4agg.py",
> line 72, in __init__
> FigureCanvasQT.__init__(self, figure)
> File
> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt4.py",
> line 68, in __init__
> _create_qApp()
> File
> "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5.py",
> line 138, in _create_qApp
> raise RuntimeError('Invalid DISPLAY variable')
> RuntimeError: Invalid DISPLAY variable
>
> What is causing these errors and how do I resolve this issue? Also echo
> $DISPLAY is blank.
>
> Thank you for your time.
>
> -Jason
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20150917/d1144b84/attachment.html>
More information about the Matplotlib-users
mailing list