KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm having a problem distributing an application that utilizes pytz . I'm using Py2Exe to create an executable from my Python source. For a simple example of the problem I'm having, I have: pytz_test.py: import pytz tz_au = pytz.timezone("Australia/Sydney") print tz_au and in setup.py: from distutils.core import setup import py2exe setup(console=['pytz_test.py'], options={"py2exe" : { 'packages': ['pytz'], } }) I then run setup.py: python setup.py py2exe Which compiles the executable. Running the created pytz_test.exe I get: Traceback (most recent call last): File "pytz_test.py", line 3, in <module> tz_au = pytz.timezone("Australia/Sydney") File "pytz\__init__.pyc", line 185, in timezone pytz.exceptions.UnknownTimeZoneError: 'Australia/Sydney' I assume it is because the timezone information isn't getting bundled with the executable, but I'm not sure how to make it happen. EDIT: A simple solution would be to add the zoneinfo directory, from the pytz module in the python site-packages directory, to the library.zip . To do this automatically, I followed the solution in that project Google Transit Data Feed used, from: http://code.google.com/p/googletransitdatafeed/source/browse/trunk/python/setup.py My modified setup.py now looks like: from distutils.core import setup import glob import py2exe options = { "py2exe" : { "compressed": 1, "optimize": 2, 'packages': ['pytz'], } } setup(console=['pytz_test.py'], options=options) import pytz import os import zipfile zipfile_path = os.path.join("dist/" 'library.zip') z = zipfile.ZipFile(zipfile_path, 'a')
Tags (comma-separated)
Save Edits
Cancel