how to freeze your matplotlib apps using py2exe

I'm trying to 'freeze' a script of mine using py2exe and I cant seem to get it to play nicely with matplotlib. More specifically, my script is a wxpython frame that displays several data plots that are created with the Agg backend and converted to bitmaps. From my limited knowledge of py2exe it appears that the problem arises from py2exe trying to import several backends at once.

My specific setup is as follows:

Followed all the steps listed here: http://sourceforge.net/mailarchive/forum.php?thread_id=4031953&forum_id=33405
Also attempted using excludes as mentioned here: http://starship.python.net/crew/theller/moin.cgi/MatPlotLib

# setup.py
from distutils.core import setup
import py2exe
import glob

data = glob.glob(r"C:\Python23\share\matplotlib\*")

opts = {'py2exe': { 'excludes': ['_gtkagg', '_tkagg'],
                            'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll']
                          }
           }

setup(
     name="Sleepy",
     version="0.5.0",
     console=["sleepy.py"],
     data_files=[("share",data)],
     options = opt
)

#fsleepy.py import list if it helps at all
import wx
from wxPython.wx import *
from wxPython.gizmos import wxTreeListCtrl
from wxPython.lib.buttons import *

import matplotlib
import matplotlib.ft2font
import matplotlib.backends.backend_agg
import ttfquery
from matplotlib.matlab import *
matplotlib.use('Agg')

from matplotlib.backends.backend_agg import FigureCanvasAgg
from matplotlib.figure import Figure
from matplotlib.axes import Subplot

import win32com.client
import pickle, math, string, calendar, time, os, os.path

Finally, I'll attach output from two runs of py2exe on the target with and without the excludes listed in the py2exe wiki.

Thanks,
-Colin

output.txt (29.6 KB)