matplotlib: no interactive backends appear to work
John Owens
john_owens at yahoo.com
Sat Jan 26 09:29:56 PST 2008
In macports, matplotlib is not working quite like I'd like. I've
installed it for both python24 and python25. It appears the
dependencies aren't quite right (sufficient) so I have manually
installed a few packages besides the normal dependencies; this bears
further investigation but I'd have to uninstall a bunch of things to
properly test it out so I'll leave that alone for now. Anyway: I'd
like this package to work with the large variety of backends that
matplotlib supports, so I am going through them now to point out
issues with the current install.
This is the current MacPorts (1.6) with 10.5.1 on Intel (MacBook Pro)
and the latest portfiles.
Summary: No interactive backends work at all. I'm not asking for every
backend to work, but at least some of them would be nice. I'd think
about prioritizing TkAgg and making sure that pdf in 2.5 also works.
First, I've installed both python24 and python25:
$ port installed | grep matplotlib
py-matplotlib @0.90.1_0+numpy+tkinter (active)
py25-matplotlib @0.90.1_1+numpy+tkinter (active)
I can configure the backend by setting it in
~/.matplotlib/matplotlibrc. That is the only setting I have in this
file, so everything else is default.
I am testing this with 'test.py', the simplest possible matplotlib
program:
from pylab import *
plot([1,2,3,4])
show() # for interactive, or savefig('test') for file
and running with python2.4 test.py (or python2.5 test.py).
OK, let's start looking at backends. First, the file-saving backends,
then the interactive ones.
++++++++ backend: Pdf ++++++++
2.4: Writes pdf correctly (woo hoo!).
2.5: Fails with AttributeError: 'module' object has no attribute 'decoding_map'
$ python2.5 test.py
Traceback (most recent call last):
File "test.py", line 4, in <module>
savefig('test')
File "/opt/local/lib/python2.5/site-packages/matplotlib/pylab.py", line 796,
in savefig
return fig.savefig(*args, **kwargs)
File "/opt/local/lib/python2.5/site-packages/matplotlib/figure.py", line 759,
in savefig
self.canvas.print_figure(*args, **kwargs)
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 1395, in print_figure
file.close()
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 401, in close
self.writeFonts()
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 456, in writeFonts
fontdictObject = self.embedTTF(filename)
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 508, in embedTTF
widths = [ get_char_width(charcode) for charcode in range(firstchar,
lastchar+1) ]
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_pdf.py",
line 505, in get_char_width
unicode = cp1252.decoding_map[charcode] or 0
AttributeError: 'module' object has no attribute 'decoding_map'
++++++++ backend: Ps ++++++++
Appears to write both ps and eps correctly for both 2.4 and 2.5.
++++++++ backend: Svg ++++++++
Appears to write svg correctly for both 2.4 and 2.5 (openable in Firefox).
Interactive backends:
++++++++ backend: Agg ++++++++
2.4 and 2.5: Launches and completes, does not pop up any graph
(window) as it should.
++++++++ backend: Cairo ++++++++
2.4 and 2.5: Same behavior, 'ImportError: No module named cairo'
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_cairo.py",
line 27, in ?
import cairo
ImportError: No module named cairo
$ port installed | grep -i cairo
cairo @1.4.10_0
cairo @1.4.12_0
cairo @1.4.14_0 (active)
++++++++ backend: CocoaAgg ++++++++
$ python2.4 test.py
The CococaAgg backend required PyObjC to be installed!
(currently testing v1.3.7)
$ python2.5 test.py
The CococaAgg backend required PyObjC to be installed!
(currently testing v1.3.7)
++++++++ backend: FltkAgg ++++++++
2.4 and 2.5: Same behavior, 'ImportError: No module named fltk'
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_fltkagg.py",
line 15, in ?
import fltk as Fltk
ImportError: No module named fltk
++++++++ backend: Gtk AND GtkAgg ++++++++
2.4 and 2.5: Same behavior, 'ImportError: No module named gobject'
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py",
line 10, in ?
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK,
FigureCanvasGTK,\
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py",
line 6, in ?
import gobject
ImportError: No module named gobject
++++++++ backend: GtkCairo ++++++++
2.4 and 2.5: Same behavior, 'ImportError: No module named gtk'
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_gtkcairo.py",
line 5, in ?
import gtk
ImportError: No module named gtk
++++++++ backend: QtAgg ++++++++
2.4 and 2.5: Same behavior, 'ImportError: No module named qt
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_qtagg.py",
line 13, in ?
from backend_qt import qt, FigureManagerQT, FigureCanvasQT,\
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_qt.py", line
20, in ?
import qt
ImportError: No module named qt
++++++++ backend: Qt4Agg ++++++++
2.4 and 2.5: Same behavior, 'ImportError: No module named PyQt4'
Traceback (most recent call last):
File "test.py", line 1, in <module>
from pylab import *
File "/opt/local/lib/python2.5/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/opt/local/lib/python2.5/site-packages/matplotlib/pylab.py", line 222,
in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.5/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 14, in <module>
from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_qt4.py",
line 20, in <module>
from PyQt4 import QtCore, QtGui
ImportError: No module named PyQt4
++++++++ backend: TkAgg ++++++++
2.4: Launches X, pops up a blank window labeled Figure 1, segfaults
python.
2.5:
Traceback (most recent call last):
File "test.py", line 1, in <module>
from pylab import *
File "/opt/local/lib/python2.5/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/opt/local/lib/python2.5/site-packages/matplotlib/pylab.py", line 222,
in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.5/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.py",
line 7, in <module>
import Tkinter as Tk, FileDialog
File "/opt/local/lib/python2.5/lib-tk/Tkinter.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
++++++++ backend: Wx ++++++++
$ python2.4 test.py
Matplotlib backend_wx requires wxPython be installed
$ python2.5 test.py
This program needs access to the screen.
Please run with 'pythonw', not 'python', and only when you are logged
in on the main display of your Mac.
$ pythonw2.4 test.py
Matplotlib backend_wx requires wxPython be installed
$ pythonw2.5 test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from pylab import *
ImportError: No module named pylab
++++++++ backend: WxAgg ++++++++
$ python2.4 test.py
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py",
line 19, in ?
import wx
ImportError: No module named wx
$ python2.5 test.py
This program needs access to the screen.
Please run with 'pythonw', not 'python', and only when you are logged
in on the main display of your Mac.
$ pythonw2.4 test.py
Traceback (most recent call last):
File "test.py", line 1, in ?
from pylab import *
File "/opt/local/lib/python2.4/site-packages/pylab.py", line 1, in ?
from matplotlib.pylab import *
File "/opt/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 222, in ?
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/opt/local/lib/python2.4/site-packages/matplotlib/backends/__init__.py",
line 24, in pylab_setup
globals(),locals(),[backend_name])
File
"/opt/local/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py",
line 19, in ?
import wx
ImportError: No module named wx
$ pythonw2.5 test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from pylab import *
ImportError: No module named pylab
/* end of message */
More information about the macports-users
mailing list