Matplotlib, py2exe and pytz

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scott

    #1

    Matplotlib, py2exe and pytz

    I am trying to convert a python app that uses matplotlib to a
    standalone executable using py2exe.

    After running py2exe and executing my app I get the following stack
    trace:

    Traceback (most recent call last):
    File "gcToCsv.py ", line 5, in ?
    File "plot_output.py c", line 1, in ?
    File "pylab.pyc" , line 1, in ?
    File "matplotlib\pyl ab.pyc", line 194, in ?
    File "matplotlib\axe s.pyc", line 46, in ?
    File "matplotlib\dat es.pyc", line 94, in ?
    File "pytz\__init__. pyc", line 53, in timezone
    KeyError: 'UTC'

    It appears that the instructions on the matplotlib web site and wiki
    are incomplete and the pytz.zoneinfo package is not being included in
    the finished dist directory.

    I tried adding an opt line to setup.py
    opts = {"py2exe": {"packages": ["pytz\zonei nfo"] } }
    but still no joy.

    Can someone tell me the correct setup.py file to use for including
    matplotlib with an app using py2exe?

    Thanks,

    Scott

  • John Hunter

    #2
    Re: Matplotlib, py2exe and pytz

    >>>>> "scott" == scott <sh_snyder@yaho o.com> writes:

    scott> I am trying to convert a python app that uses matplotlib to
    scott> a standalone executable using py2exe.

    scott> After running py2exe and executing my app I get the
    scott> following stack trace:

    scott> Traceback (most recent call last): File "gcToCsv.py ", line
    scott> 5, in ? File "plot_output.py c", line 1, in ? File
    scott> "pylab.pyc" , line 1, in ? File "matplotlib\pyl ab.pyc",
    scott> line 194, in ? File "matplotlib\axe s.pyc", line 46, in ?
    scott> File "matplotlib\dat es.pyc", line 94, in ? File
    scott> "pytz\__init__. pyc", line 53, in timezone KeyError: 'UTC'

    scott> It appears that the instructions on the matplotlib web site
    scott> and wiki are incomplete and the pytz.zoneinfo package is
    scott> not being included in the finished dist directory.

    In your script that you are trying to freeze, do,

    import pytz
    import dateutil

    as a hint to py2exe that you want these modules. Does this help?

    Does the script you are trying to freeze explicitly use matplotlib
    date functionality?

    JDH

    Comment

    • scott

      #3
      Re: Matplotlib, py2exe and pytz

      I unzipped library.zip to see what compiled python files were included
      in the zip.
      As in the error stacktrace the Pytz.timezone package was not part of
      the library.
      After manually adding it and rezipping the library I ran into another
      missing module, this time it was missing backend_agg

      Traceback (most recent call last):
      File "gcToCsv.py ", line 5, in ?
      File "plot_output.py c", line 1, in ?
      File "pylab.pyc" , line 1, in ?
      File "matplotlib\pyl ab.pyc", line 195, in ?
      File "matplotlib\bac kends\__init__. pyc", line 20, in ?
      ImportError: No module named backend_agg

      I added that module and then saw that it was missing pyparsing
      Traceback (most recent call last):
      File "gcToCsv.py ", line 5, in ?
      File "plot_output.py c", line 1, in ?
      File "pylab.pyc" , line 1, in ?
      File "matplotlib\pyl ab.pyc", line 195, in ?
      File "C:\PYTHON23\Li b\site-packages\matplo tlib\backends\_ _init__.py",
      line 20,
      in ?
      globals(),local s(),[backend_name])
      File
      "C:\PYTHON23\Li b\site-packages\matplo tlib\backends\b ackend_agg.py",
      line
      85, in ?
      from matplotlib.math text import math_parse_s_ft 2font
      File "C:\PYTHON23\Li b\site-packages\matplo tlib\mathtext.p y", line
      140, in ?
      from matplotlib.pypa rsing import Literal, Word, OneOrMore,
      ZeroOrMore, \
      ImportError: No module named pyparsing

      After that I stopped adding modules as I figured the problem was more
      involved than just missing 1 or 2 modules.

      My app just takes a set of data and plots it using the library. It does
      not use matplotlib date functionality explicitly, it converts a list of
      datatimes to a list of elapsed times (numbers of seconds) and plots
      data against these floats.

      The setup.py file I used was the one in the matplotlib documentation. I
      then added the opt line to try and force the inclusion of that package.


      I am relatively new to Python programming coming most recently from a
      Java programming background, and was wondering why python does not have
      the concept of a python archive much like a "jar" file in Java.
      That would make all of these problems fairly trivial, inclusion of
      dependant libraries would just be a matter of having the appropriate
      "Python ARchive in a directory in the PYTHON_PATH so that it could be
      loaded.

      Thanks for any help on resolving my py2exe problems.

      Scott Snyder

      Comment

      Working...