如何在 Raspberry Pi 上修复未知时区 Pytz?

How to fix unknown timezone Pytz on a Raspberry Pi?

我在我的 Pi3 上遇到一个很大的回溯错误,Pytz 似乎无法设置本地时间。我应该如何解决这个问题?

这是我认为有问题的行:

    line 181, in timezone
    raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'SystemV/EST5EDT'

这是回溯

Traceback (most recent call last):
  File "unexpected.py", line 202, in <module>
    sched = BackgroundScheduler()
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/apscheduler/schedulers/base.py", line 82, in __init__
    self.configure(gconfig, **options)
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/apscheduler/schedulers/base.py", line 121, in configure
    self._configure(config)
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/apscheduler/schedulers/background.py", line 29, in _configure
    super(BackgroundScheduler, self)._configure(config)
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/apscheduler/schedulers/base.py", line 689, in _configure
    self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/tzlocal/unix.py", line 131, in get_localzone
    _cache_tz = _get_localzone()
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/tzlocal/unix.py", line 70, in _get_localzone
    return pytz.timezone(etctz.replace(' ', '_'))
  File "/home/pi/Documents/flask_projects/unexpected_two/venv/lib/python3.4/site-packages/pytz/__init__.py", line 181, in timezone
    raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'SystemV/EST5EDT'

谢谢!

The SystemV time zones are usually not included in various distributions of the tz database. It would be quite odd to expect Unix System V 专有构造可用于 Raspberry Pi。

确实,如果导出 all_timezones 列表(在任何环境中)- 您将不会在其中找到 SystemV 时区。 Pytz 不包括它们。

我建议你看看List of TZ Database Time Zones选择一个更合理的时区。例如,如果您指的是美国遵守的东部时间,那么您应该改用 America/New_York