Matplotlib, py2exe and pytz

S

scott

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
 
J

John Hunter

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
 
S

scott

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top