Matplotlib+GTKAgg+py2exe

All,

I have experience getting MPL working with wx backend with py2exe, and I have sucessfully packaged and delivered py2exe executables (email me if you would like a copy of the setup.py file that worked for me).

I have decided to switch my main development from wx to GTK since Glade is so much easier to use (and get support for) than wxGlade.

Now my main problem is getting GTK to play nicely with MPL and py2exe. So far Ive had no luck. The program runs perfectly when not packaged into an executable FWIW. I copied my setup.py file at the end of the email. Perhaps someone has an idea. I import MPL with

import matplotlib

matplotlib.use(‘GTKAgg’)

which immediately spits out an error:

(GTKAPP.exe:4188): GdkPixbuf-WARNING **: Cannot open pixbuf loader module file ‘gtk-2.0\gdk-pixbuf.loaders’: No such file or directory

I tried to follow the recommendations of http://www.py2exe.org/index.cgi/Py2exeAndPyGTK with moving the etc, share, lib folders to the dist folder and I even in desperation added the etc, share and lib folders to the path prior to importing MPL. No dice.

Any thoughts?

My setup.py that doesn’t work with GTKAgg:

from distutils.core import setup

import py2exe

excludes = [’_tkagg’, ‘_wxagg’,’_wx’,’_cocoaagg’,’_fltkagg’,‘bsddb’, ‘curses’, ‘pywin.debugger’,

‘pywin.debugger.dbgcon’, ‘pywin.dialogs’, ‘tcl’,

‘Tkconstants’, ‘Tkinter’, ‘pydoc’, ‘doctest’, ‘test’, ‘sqlite3’,

‘projections’,‘Tcl’,‘PyQT4’,‘qt’,‘backend_qt’,‘backend_qt4’,‘backend_qt4agg’,

‘backend_qtagg’,‘backend_cairo’,‘backend_cocoaagg’,‘wx’,‘scipy.sparse’

]

dll_excludes = [‘QTGui4.dll’,‘QtCore4.dll’,‘tk85.dll’,‘tcl85.dll’]

data_files=[‘CurveFit.ui’,]

packages = [‘pygtk’,‘matplotlib’,‘encodings’,‘gtk’]

includes = [‘cairo’,‘pangocairo’,‘atk’,‘gobject’,‘pango’]

import matplotlib as mpl

data_files += mpl.get_py2exe_datafiles()

setup(

name = ‘FitTool’,

description = ‘CurveFittingTool’,

version = ‘0.1’,

console = [

{

‘script’: ‘GTKAPP.py’,

}

],

options = {“py2exe”: {“compressed”: 2,

“optimize”: 2,

“excludes”: excludes,

“packages”: packages,

“includes”: includes,

“dll_excludes”: dll_excludes,

using 2 to reduce number of files in dist folder

using 1 is not recommended as it often does not work

“bundle_files”: 2,

“dist_dir”: ‘dist’,

“xref”: False,

“skip_archive”: False,

“ascii”: False,

“custom_boot_script”: ‘’,

}

},

using zipfile to reduce number of files in dist

zipfile = r’libFiles\library.zip’,

data_files=data_files

)

···

Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University

email: ibell@…2939…
cell: (607)227-7626