Search code examples
timezoneraspberry-pi3pytzapscheduler

How to fix unknown timezone Pytz on a Raspberry Pi?


I am getting a large traceback error on my Pi3, Pytz can't seem to set the local time. How should I go about solving this?

Here's the line that I think is the issue:

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

Here's the traceback

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'

Thanks!


Solution

  • 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 proprietary constructs to work on a Raspberry Pi.

    Indeed, if one exports the all_timezones list (in any environment) - you will not find the SystemV time zones in there. Pytz does not include them.

    I suggest you take a look at the List of TZ Database Time Zones to choose a more reasonable time zone. For example, if you meant Eastern Time as observed by the United States, then you should use America/New_York instead.