Strange pytz import issue — pytz.UnknownTimeZoneEr

2019-09-05 00:05发布

问题:

I am having trouble importing a valid timezone on a pytz install.

When I run this:

python -c "import pytz; print pytz.timezone('America/New_York')"

In my home folder I have this output:

$ python -c "import pytz; print pytz.timezone('America/New_York')"
America/New_York

But if I cd into a different folder off of my home directory, I get this output:

$ cd webapp/
$ python -c "import pytz; print pytz.timezone('America/New_York')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "pytz/__init__.py", line 173, in timezone
    raise UnknownTimeZoneError(zone)
pytz.UnknownTimeZoneError: 'America/New_York'

It seems to be loading pytz incorrectly..? Is there a way I can figure out why it's loading it differently, and how I can restore default behavior? Thanks!