no gdk backend with macports and snow leopard

I am having the old “no gdk backend” problem with GTKAgg. I am running OS X 10.6 (Snow Leopard), and, uh, I’m kind of new to Unix :). I installed the following through Macports:

python26 @2.6.6_3 (active)

py26-gtk @2.22.0_1 (active)

py26-matplotlib @1.0.1_3+tkinter (active)

py26-numpy @1.6.0_0+atlas+gcc44 (active)

and the following code:

from numpy import *

import gtk

import gobject

import matplotlib


import matplotlib.pyplot
as plt

gives the following error on the pyplot import:

pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)

pydev debugger: starting

Xlib: extension “RANDR” missing on display “/tmp/launch-KDlxaE/org.x:0”.

Traceback (most recent call last):

File “/Applications/eclipseJavaHelios/plugins/org.python.pydev.debug_2.0.0.2011040403/pysrc/”, line 1134, in['file'], None, None)

File “/Applications/eclipseJavaHelios/plugins/org.python.pydev.debug_2.0.0.2011040403/pysrc/”, line 918, in run

pydev_imports.execfile(file, globals, locals) #execute the script

File “/Users/jwjameson/Dropbox/mine/PyStuff/workspace/Continuous/Pothead/”, line 20, in

import matplotlib.pyplot as plt

File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/”, line 95, in

new_figure_manager, draw_if_interactive, show = pylab_setup()

File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/”, line 25, in pylab_setup


File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/”, line 10, in

from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\

File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/”, line 28, in

from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK

File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/”, line 29, in

from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array

ImportError: No module named _backend_gdk

I noticed the page:

says nothing about Macports.

I noticed the page

where Mr. Hunter says:

matplotlib is probably not finding pygtk at build time – you need
have pkg-config installed, and locate your pygtk-2.0.pc file and then
add that path to your PKG_CONFIG_PATH. You can check the output of
the build script at the beginning in the section

libpng: 1.2.27
Tkinter: Tkinter: 50704, Tk: 8.4, Tcl: 8.4
* WxAgg extension not required for wxPython >= 2.8
Gtk+: gtk+: 2.14.4, glib: 2.18.2, pygtk: 2.13.0,
pygobject: 2.15.3
Mac OS X native: no
Qt: Qt: 3.3.8, PyQt: 3.17.4
Qt4: Qt: 4.4.3, PyQt4: 4.4.4
Cairo: 1.4.12

You need to have an entry for Gtk or else the backend will not be built.

but I have no idea how to utilize this info with Macports. I was not able to locate a pygtk-2.0.pc file. If there were such a file, would Macports look at it to configure the matplotlib installation as I would like (to be able to use the GTKAgg backend)?

Any suggestions are greatly appreciated!