Differences between revisions 3 and 31 (spanning 28 versions)
Revision 3 as of 2004-05-19 18:23:14
Size: 2085
Editor: 206
Comment:
Revision 31 as of 2018-10-15 12:22:37
Size: 204
Editor: MadelaineP
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Introduction =
matplotlib [http://matplotlib.sf.net] 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.
= Changes required to matplotlib =
I had to patch matplotlib's __init__.py file in the get_data_path() routine. Specifically, right before raising the error at the end, I added the following code
{{{
#!python
      # CODE ADDED TO SUPPORT PY2EXE
      if sys.frozen:
         path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlib')
         return path
}}}
= Special content for setup.py to use matplotlib =
We also need to make sure we get the matplotlib subdirectory created in the distribution. This is where we'll include all of the stuff matplotlib includes in the pythonXX\share\matplotlib directory. This is also where the __init__ file has been updated to look for this information.
{{{
#!python
# We need to import the glob module to search for all files.
import glob

# We need to exclude matplotlib backends not being used by this executable. You may find
# that you need different excludes to create a working executable with your chosen backend.
opts = {
    'py2exe': { 'excludes': ['_gtkagg', '_tkagg'],
                'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                 'libgobject-2.0-0.dll']}

# Additional data files are required by matplotlib. Note that the glob.glob routine
# doesn't seem to pick up the .matplotlib resource file, so I copy that separately.
setup(
    data_files = [('matplotlib', glob.glob(r'c:\python23\share\matplotlib\*')),
                  ('matplotlib', [r'c:\python23\share\matplotlib\.matplotlibrc'])],
    name = 'demo',
    description = 'MatPlotLib Demo Program',
    console = ['demo.py',]
    )

}}}
Im Madelaine and was born on 3 November 1990. My hobbies are Parkour and Tai Chi.<<<BR>>
><<<BR>>
>
<<<BR>>
><<<BR>>
>
My weblog: pay off credit card ([[https://www.trubeta.com/|www.trubeta.com]])

Im Madelaine and was born on 3 November 1990. My hobbies are Parkour and Tai Chi.<
><
> <
><
> My weblog: pay off credit card (www.trubeta.com)

MatPlotLib (last edited 2018-10-31 15:57:34 by JimmyRetzlaff)