Closed dkabus closed 2 years ago
Since the upgrade to version 0.18.0, the module throws this error when running
dav2rem
on Arch Linux:zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key localtime'
Seems like you are missing a:
sudo ln -s /etc/localtime /usr/share/zoneinfo/localtime
That is provided in Debian by the tzdata package.
I could implement a fallback to /etc/localtime and afterwards to UTC but not sure why Python doesn't do that itself.
Thanks, that symlink fixes it.
Indeed it is weird that Python doesn't check for this as a fallback.
timedatectl
which is part of systemd
only sets /etc/localtime
(see man timedatectl
and man 5 localtime
).
Indeed it is weird that Python doesn't check for this as a fallback.
I understand this is a compile configuration problem:
Debian: python3 -c "from zoneinfo import TZPATH; print(TZPATH)" ('/usr/share/zoneinfo', '/usr/lib/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo')
Arch: python3 -c "from zoneinfo import TZPATH; print(TZPATH)" ('/usr/share/zoneinfo',)
OpenBSD: ('/usr/share/zoneinfo', '/usr/lib/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo')
So it can't find /etc/localtime. Not sure if python-remind should work around that.
~I'm experiencing this on OpenBSD-current. I tried creating /etc/zoneinfo
by running ln -s /usr/share/zoneinfo/UTC /etc/zoneinfo
, but it doesn't help; see below output. Setting TZ=America/Toronto
in the environment (which is the usual way I pass on time zone information) doesn't help either.~
~I can't see any documentation claiming that ZoneInfo("localtime")
should work. There's mention of this at https://github.com/regebro/tzlocal/issues/117.~
~I guess one option could be to use the tzlocal
module? But that would be another dependency. Alternatively, I personally wouldn't mind passing the time zone as a command-line option to dav2rem
(which is the tool I'm actually trying to use) so the fallback to ZoneInfo("localtime")
never gets triggered.~
moth ~ $ python3
Python 3.10.9 (main, Jan 10 2023, 16:10:16) [Clang 13.0.0 ] on openbsd7
Type "help", "copyright", "credits" or "license" for more information.
>>> import remind
>>> remind.Remind("f.rem")
Traceback (most recent call last):
File "/usr/local/lib/python3.10/zoneinfo/_common.py", line 12, in load_tzdata
return importlib.resources.open_binary(package_name, resource_name)
File "/usr/local/lib/python3.10/importlib/resources.py", line 43, in open_binary
package = _common.get_package(package)
File "/usr/local/lib/python3.10/importlib/_common.py", line 66, in get_package
resolved = resolve(package)
File "/usr/local/lib/python3.10/importlib/_common.py", line 57, in resolve
return cand if isinstance(cand, types.ModuleType) else importlib.import_module(cand)
File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tzdata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/falsifian/.local/lib/python3.10/site-packages/remind.py", line 55, in __init__
self._localtz = localtz if localtz else ZoneInfo("localtime")
File "/usr/local/lib/python3.10/zoneinfo/_common.py", line 24, in load_tzdata
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key localtime'
>>>
Sorry, never mind. This is fixed in master. I was using 0.18.
Since the upgrade to version 0.18.0, the module throws this error when running
dav2rem
on Arch Linux:I have installed the package from the AUR and am currently on version 0.18.0.r0.gc30c852-1. Downgrading the package via
pip install remind==0.17.0
fixes this issue.Here the full error message:
Thank you maintaining this fantastic tool! It's very much appreciated.