From: Werner F. B. <wer...@fr...> - 2007-11-27 10:48:11
|
John, John Penney wrote: > Hello, > I have a Python application (Python 2,4) that makes extensive use of > pytz, but am having problems getting py2exe to build the application > properly. My application fails at: > > File "pytz\__init__.pyc", line 71, in timezone > None > KeyError: 'Europe/London' > > It seems to be because the subdirectories of pytz (e.g > zoneinfo/Europe/London) have not been added into the zip file. If I > manually add the whole pytz folder into the zip file it seems to work fine. > > I've had a brief look at pytz and what is unusual is that there isn't an > explicit dependency on the packages underneath the pytz folder. They > are built dynamically at run time like this (where zone = > 'Europe/London' in my case): > > zone_bits = ['zoneinfo'] + zone.split('/') > # Load zone's module > module_name = '.'.join(zone_bits) > try: > module = __import__(module_name, globals(), locals()) > except ImportError: > raise KeyError, zone # <--- Here's where my py2exe built app fails > > Am I expecting too much to expect pytz to handle this? > > Is there a better workaround than just manually adding pytz to the > library.zip file? Just force py2exe to include part or all of the pytz package, in my case I only need UTC so I do: options = {"py2exe": {"compressed": 1, "optimize": 2, "packages": ["encodings", "kinterbasdb", "pytz.zoneinfo.UTC", "matplotlib.numerix", "email", ], Werner > > Thanks in advance! > > John > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > ------------------------------------------------------------------------ > > _______________________________________________ > Py2exe-users mailing list > Py2...@li... > https://lists.sourceforge.net/lists/listinfo/py2exe-users |