Strange pytz import issue — pytz.UnknownTimeZoneError with valid timezone

♀尐吖头ヾ 提交于 2019-12-25 02:02:02

问题


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!

来源:https://stackoverflow.com/questions/21028464/strange-pytz-import-issue-pytz-unknowntimezoneerror-with-valid-timezone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!