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 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 file at the end of the email. Perhaps someone has an idea. I import MPL with

import matplotlib


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 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 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’,




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


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

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

import matplotlib as mpl

data_files += mpl.get_py2exe_datafiles()


name = ‘FitTool’,

description = ‘CurveFittingTool’,

version = ‘0.1’,

console = [


‘script’: ‘’,



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\’,




Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University

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