Matplotlib – Python Error
Question:
Setup:
Processor : x86_64
Operating System: GNU/Linux
Distro: Fedora Release 13 (Goddard).
Python 2.6.4
/usr/bin/python
Here is the following issue:
I am trying to generate a few graphs using Matplotlib and Python. As I hear from a majority of the solutions3.. there seem to be compatibility issues between matplotlib and 64bit architectures.
I have installed Matplotlib from here
Here is the error that I get:
Traceback (most recent call last):
File "plot-thread-characterization.py", line 24, in <module>
import matplotlib.pyplot as plt
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module>
import gtk; gdk = gtk.gdk
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
_init()
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display
Thanks.
Answers:
matplotlib is failing to connect to any X server for its GTK display.
There are a couple of options here:
-
Run a local X server and enable X11 forwarding in your ssh client, to display the output on your local machine. You can verify this is working by checking that the $DISPLAY environment variable is set on the server.
-
Call matplotlib.use(…) to specify a different display back-end, for example rendering to pdf file, before importing pyplot, e.g.
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
See http://matplotlib.org/faq/howto_faq.html#generate-images-without-having-a-window-appear for more details.
Setup:
Processor : x86_64
Operating System: GNU/Linux
Distro: Fedora Release 13 (Goddard).
Python 2.6.4
/usr/bin/python
Here is the following issue:
I am trying to generate a few graphs using Matplotlib and Python. As I hear from a majority of the solutions3.. there seem to be compatibility issues between matplotlib and 64bit architectures.
I have installed Matplotlib from here
Here is the error that I get:
Traceback (most recent call last):
File "plot-thread-characterization.py", line 24, in <module>
import matplotlib.pyplot as plt
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module>
import gtk; gdk = gtk.gdk
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
_init()
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display
Thanks.
matplotlib is failing to connect to any X server for its GTK display.
There are a couple of options here:
-
Run a local X server and enable X11 forwarding in your ssh client, to display the output on your local machine. You can verify this is working by checking that the $DISPLAY environment variable is set on the server.
-
Call matplotlib.use(…) to specify a different display back-end, for example rendering to pdf file, before importing pyplot, e.g.
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
See http://matplotlib.org/faq/howto_faq.html#generate-images-without-having-a-window-appear for more details.