stub42/pytz

Can't run Django - No Time Zone Found Error

colinschwegmann opened this issue · 8 comments

Can't start my Django if I set the version 2022.2:

Command: python manage.py produces the following output:

zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Asia/Hanoi'

If I set requirements version to pytz==2022.1 then it works fine.

Please advise.

I am facing the same

Same, but doesn't this belong at django?

Probably both. It's definitely the requirement that needs to be adjusted before Django issues a fix (you likely can't change Django versions to fix this issue).

Same here, like @colinschwegmann said, setting requirements to

pytz==2022.1

it works.

Opened a ticket in Django here: https://code.djangoproject.com/ticket/33922

Actually the problem is not in Django itself, I was creating a new repository using only Django 3.2 and the problem does not exists.
In my case, the problem seems to be related to this package: django-timezone-field
Related issue: mfogel/django-timezone-field#94

This morning i'm facing the same, i'm downgrade pytz==2022.1 now for continue woking

The 2022.2 release contains a working Asia/Hanoi:

Python 3.8.10 (default, Jun  2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytz
>>> pytz.timezone('Asia/Hanoi')
<DstTzInfo 'Asia/Hanoi' LMT+7:03:00 STD>
>>> 'Asia/Hanoi' in pytz.common_timezones_set
True

However, 2022.1 does not:

Python 3.8.10 (default, Jun  2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytz
>>> 'Asia/Hanoi' in pytz.common_timezones
False
>>> 'Asia/Hanoi' in pytz.all_timezones
False
>>> pytz.__version__
'2022.1'

I think this is a conflict between the tzdata package (latest version as of writing this 2022.1) and pytz 2022.2.

Actually the problem is not in Django itself, I was creating a new repository using only Django 3.2 and the problem does not exists. In my case, the problem seems to be related to this package: django-timezone-field Related issue: mfogel/django-timezone-field#94

Yes, django-timezone-field is iterating over pytz.common_timezones and then using zoneinfo.ZoneInfo() to instantiate the tzinfo objects. Which fails, because they haven't been updated to include the new timezone yet. It needs to catch the exception, because it can't assume there is not drift between the packages, or not use pytz at all.