Skip to content

ModuleNotFoundError: No module named 'zoneinfo' #122

@amotl

Description

@amotl

Dear Paul,

thanks a stack for maintaining this package. I just used it for the very first time, and copied the snippet from the README as advertised, and how I expected it to work out of the box. Using a try/except on an ImportError is usually what we are all used to do since ages, right?

Now I was baffled to find that in this case, Python 3.8 reports a ModuleNotFoundError. I think it probably always have been like that, ImportError would only be raised in from abc import foo-style cases, where the top-level package module exists, but not a submodule.

I just wanted to make sure you agree on this before I would submit a corresponding patch to the README.

try:
    import zoneinfo
except ModuleNotFoundError:
    from backports import zoneinfo

With kind regards,
Andreas.

Reproduction

docker run --rm -it python:3.8-slim-bullseye
>>> import zoneinfo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'zoneinfo'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions