Matplotlib, py2exe and pytz

Discussion in 'Python' started by scott, Feb 19, 2005.

  1. scott

    scott Guest

    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.pyc", line 1, in ?
    File "pylab.pyc", line 1, in ?
    File "matplotlib\pylab.pyc", line 194, in ?
    File "matplotlib\axes.pyc", line 46, in ?
    File "matplotlib\dates.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\zoneinfo"] } }
    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
    scott, Feb 19, 2005
    #1
    1. Advertising

  2. scott

    John Hunter Guest

    >>>>> "scott" == scott <> 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.pyc", line 1, in ? File
    scott> "pylab.pyc", line 1, in ? File "matplotlib\pylab.pyc",
    scott> line 194, in ? File "matplotlib\axes.pyc", line 46, in ?
    scott> File "matplotlib\dates.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
    John Hunter, Feb 20, 2005
    #2
    1. Advertising

  3. scott

    scott Guest

    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.pyc", line 1, in ?
    File "pylab.pyc", line 1, in ?
    File "matplotlib\pylab.pyc", line 195, in ?
    File "matplotlib\backends\__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.pyc", line 1, in ?
    File "pylab.pyc", line 1, in ?
    File "matplotlib\pylab.pyc", line 195, in ?
    File "C:\PYTHON23\Lib\site-packages\matplotlib\backends\__init__.py",
    line 20,
    in ?
    globals(),locals(),[backend_name])
    File
    "C:\PYTHON23\Lib\site-packages\matplotlib\backends\backend_agg.py",
    line
    85, in ?
    from matplotlib.mathtext import math_parse_s_ft2font
    File "C:\PYTHON23\Lib\site-packages\matplotlib\mathtext.py", line
    140, in ?
    from matplotlib.pyparsing 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
    scott, Feb 20, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dr. Colombes
    Replies:
    3
    Views:
    651
    John Hunter
    Feb 23, 2005
  2. nicolas_riesch

    how to write thread-safe module ? and pytz

    nicolas_riesch, Aug 10, 2005, in forum: Python
    Replies:
    5
    Views:
    394
    nicolas_riesch
    Aug 15, 2005
  3. David Pratt

    Datetime, pytz and strange offset

    David Pratt, Dec 13, 2005, in forum: Python
    Replies:
    0
    Views:
    440
    David Pratt
    Dec 13, 2005
  4. Sanjay
    Replies:
    2
    Views:
    409
    Sanjay
    Jul 18, 2007
  5. Sanjay
    Replies:
    0
    Views:
    362
    Sanjay
    Jul 13, 2007
Loading...

Share This Page