[ MatPlotLib] is a module to produce nice-looking plots in Python using a wide variety of back-end packages, at least one of which is likely to be available for your system. This ability to do things in a generic fashion makes this a simple system to use, but it gets complicated if you wish to distribute an executable instead of scripts. This page describes what I had to do to make matplotlib work with py2exe.

Special content for to use matplotlib

   1 # We need to import the glob module to search for all files.
   2 import glob
   4 # We need to exclude matplotlib backends not being used by this executable.  You may find
   5 # that you need different excludes to create a working executable with your chosen backend.
   6 # We also need to include matplotlib.numerix.random_array
   7 opts = {
   8     'py2exe': { 'includes': 'matplotlib.numerix.random_array',
   9                 'excludes': ['_gtkagg', '_tkagg'],
  10                 'dll_excludes': ['libgdk-win32-2.0-0.dll',
  11                                  'libgobject-2.0-0.dll']
  12               }
  13        }
  15 # Additional data files are required by matplotlib.  Note that the glob.glob routine
  16 # doesn't seem to pick up the .matplotlib resource file, so I copy that separately.
  17 # Do the same if you need to
  18 setup(
  19     data_files = [(r'matplotlibdata', glob.glob(r'c:\python24\share\matplotlib\*')),
  20                   (r'matplotlibdata', [r'c:\python24\share\matplotlib\.matplotlibrc'])],
  21     name = 'demo',
  22     description = 'MatPlotLib Demo Program',
  23     console = ['']
  24     )


if you end up with

  File "pytz\__init__.pyo", line 53, in timezone
KeyError: 'UTC'

in your log file then see