I am trying to use pytz in a python script, to be used as a mapper for a hadoop streaming job.
Following advice in another thread, I tried packaging pytz as a zip 'pytz.mod', and loading it with zipimport:
import zipimport
importer = zipimport.zipimporter('pytz.mod')
pytz = importer.load_module('pytz')
from pytz import timezone
user_timezone = timezone('America/Moncton')
This gives the following error:
Traceback (most recent call last):
File "./load-pytz.py", line 15, in <module>
user_timezone = timezone('America/Moncton')
File "./lib/python2.6/site-packages/pytz/__init__.py", line 180, in timezone
pytz.exceptions.UnknownTimeZoneError: 'America/Moncton'
I found this thread, and the issue seems to be that zipimport can't load binary files in the zoneinfo directory. I tried to follow instructions in the thread but could not get them to work. Is there a simpler mechanism for packaging zoneinfo, without going through py2exe?
All I need to do is to localize a UTC time stamp relative to a time zone, e.g., 'America/Moncton'.
Thank you!