Timezone Information Missing in pytz?

后端 未结 8 1547
轻奢々
轻奢々 2020-12-31 16:17

I\'m having a very weird problem with Python\'s pytz: it seems to have an incomplete catalog of timezones on my system (MacOS X 10.8.5, system Python 2.7.5).

8条回答
  •  囚心锁ツ
    2020-12-31 16:54

    Tried reinstall, but bug not gone.

    Then, I open pytz/__init__.py, add a line zone = 'UTC', problem is gone:

    zone = _unmunge_zone(zone)
    zone = 'UTC'
    if zone not in _tzinfo_cache:
        if zone in all_timezones_set:
            fp = open_resource(zone)
            try:
                _tzinfo_cache[zone] = build_tzinfo(zone, fp)
            finally:
                fp.close()
        else:
            raise UnknownTimeZoneError(zone)
    

    This is quick and simple solution, but you'd better find the real problem( version? system? ) if you have time.

提交回复
热议问题