pganssle / zoneinfo

Reference implementation for the proposed standard library module zoneinfo
Other
52 stars 20 forks source link

Missing dependency: tzdata #140

Closed woutdenolf closed 1 year ago

woutdenolf commented 1 year ago

Version: backports.zoneinfo 0.2.1 OS: windows 11 Python: 3.8

Reproduce:

from backports.zoneinfo import ZoneInfo
zinfo = ZoneInfo("UTC")

Backtrace:

Traceback (most recent call last):
  File "...\py3.8\lib\site-packages\backports\zoneinfo\_common.py", line 15, in load_tzdata
    return importlib_resources.open_binary(package_name, resource_name)
  File "C:\python\3.8\lib\importlib\resources.py", line 88, in open_binary
    package = _get_package(package)
  File "C:\python\3.8\lib\importlib\resources.py", line 47, in _get_package
    module = import_module(package)
  File "C:\python\3.8\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tzdata'

Solution:

pip install tzdata

woutdenolf commented 1 year ago

Ok I see, this is an optional dependency. I suppose this will stay optional?

pganssle commented 1 year ago

Yes, tzdata is only required on some operating systems (mostly Windows), and only used if it's required. This is the same as the standard library module.