bugfix for: ImportError: No module named _backend_gdk

Hi,

I had the following error message when I tried to install matplotlib-0.98.5.2.tar.gz from source.
The build and install process seemed to proceed without errors, but when I tried
“import pylab”, I got the following traceback:

File /usr/local/lib/python2.5/site-packages/pylab.py, line 1, in
from matplotlib.pylab import *
File /usr/local/lib/python2.5/site-packages/matplotlib/pylab.py, line 249, in

    from matplotlib.pyplot import *
File /usr/local/lib/python2.5/site-packages/matplotlib/pyplot.py, line 75, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
File /usr/local/lib/python2.5/site-packages/matplotlib/backends/init.py, line 23, in pylab_setup

    globals(),locals(),[backend_name])
File /usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py, line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK, File /usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py, line 21, in <module>

    from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
File /usr/local/lib/python2.5/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 figured out that this was due to an extra comma in setupext.py.

Edit line 1347 to remove the extra comma, changing this:

module = Extension(

‘matplotlib.backends._backend_gdk’,
[‘src/backend_gdk.c’, ], #<---- HERE IS THE BAD EXTRA COMMA
libraries = [],
include_dirs=numpy_inc_dirs,
)

to this:

module = Extension(

‘matplotlib.backends._backend_gdk’,
[‘src/backend_gdk.c’ ],
libraries = [],
include_dirs=numpy_inc_dirs,
)

Then

python setup.py build
sudo python setup.py install
python -c “import pylab”

works as expected.

This doesn't make any sense, because the two lists are identical::

In [127]: x = ['src/backend_gdk.c', ]

In [128]: len(x)
Out[128]: 1

In [129]: x
Out[129]: ['src/backend_gdk.c']

In [130]: y = ['src/backend_gdk.c']

In [131]: len(y)
Out[131]: 1

In [132]: y
Out[132]: ['src/backend_gdk.c']

In [133]: x==y
Out[133]: True

···

On Tue, Dec 23, 2008 at 11:48 PM, Balaji S. Srinivasan <balajis@...200...> wrote:

I figured out that this was due to an extra comma in setupext.py.
Edit line 1347 to remove the extra comma, changing this:

module = Extension(

'matplotlib.backends._backend_gdk',
['src/backend_gdk.c', ], #<---- HERE IS THE BAD EXTRA COMMA
libraries = [],
include_dirs=numpy_inc_dirs,
)

to this:

module = Extension(

'matplotlib.backends._backend_gdk',
['src/backend_gdk.c' ],
libraries = [],
include_dirs=numpy_inc_dirs,
)

Then