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

matplotlib.use(‘GTKAgg’)

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/pydevd.py”, line 1134, in

debugger.run(setup['file'], None, None)

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

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

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

import matplotlib.pyplot as plt

File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py”, 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/init.py”, line 25, in pylab_setup

globals(),locals(),[backend_name])

File “/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py”, 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/backend_gtk.py”, 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/backend_gdk.py”, line 29, in

from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array

ImportError: No module named _backend_gdk

I noticed the page:

http://matplotlib.sourceforge.net/faq/installing_faq.html

says nothing about Macports.

I noticed the page

http://old.nabble.com/_backend_gdk-not-found-td26514059.html

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

OPTIONAL BACKEND DEPENDENCIES
libpng: 1.2.27
Tkinter: Tkinter: 50704, Tk: 8.4, Tcl: 8.4
wxPython: 2.8.8.0
* 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!

best,

john