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:
Also attempted using excludes as mentioned here:

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']

     options = opt
) 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 *

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.


output.txt (29.6 KB)