ImportError: No module named _backend_gdk
Question: I am starting to get some insight into interactive plotting with python and
matplotlib using pyGTK+. Therefore I took a look at the example given at the
matplotlib website:

<http://matplotlib.org/examples/user_interfaces/gtk_spreadsheet.html>

This is a short exerpt of the Code:

    
    
    #!/usr/bin/env python
    """
    Example of embedding matplotlib in an application and interacting with
    a treeview to store data.  Double click on an entry to update plot
    data
    
    """
    import pygtk
    pygtk.require('2.0')
    import gtk
    from gtk import gdk
    
    import matplotlib
    matplotlib.use('GTKAgg')  # or 'GTK'
    from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
    
    from numpy.random import random
    from matplotlib.figure import Figure
    

Ones I try to run this Script in the Terminal I get the following error:

    
    
    Traceback (most recent call last):
      File "gtk_spreadsheet.py", line 15, in <module>
        from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 33, in <module>
        from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gdk.py", line 29, in <module>
        from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
    ImportError: No module named _backend_gdk
    

I have python 2.7 , matplotlib 1.2.0 and pygtk 2.24 installed.

Can anyone figure out where the error is located? I think it might be
connected to some linkin issues?

Thanks a lot!


Answer: Note that the Debian/Ubuntu package you need is not 'pygtk2-devel' but
'python-gtk2-dev':

    
    
    sudo apt-get install python-gtk2-dev
    

should fix this error on these platforms.

