[Fix] zoneinfo._common.ZoneInfoNotFoundError: ‘No time zone found with key Asia/Hanoi’

The Error “zoneinfo._common.ZoneInfoNotFoundError: ‘No time zone found with key Asia/Hanoi'”, is an error that is seen when you are working on python and using the django 4 framework to rebuild your docker container.

Given below is the snippet of the error you might get:

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

The error, “zoneinfo._common.ZoneInfoNotFoundError: ‘No time zone found with key Asia/Hanoi'” is seen because the new version of pytz release, that is version 2022.2 seems to have a lot of bugs in it. So the most optimal solution to the error is to downgrade flutter to version 2022.1 in your system

To fix the error, “zoneinfo._common.ZoneInfoNotFoundError: ‘No time zone found with key Asia/Hanoi'”, downgrade pytz to version 2022.1 because of latest version of pytz seems to have a lot of bugs in it.

Steps to fix the error “zoneinfo._common.ZoneInfoNotFoundError: ‘No time zone found with key Asia/Hanoi'” is mentioned below:

The simplest solution will be to downgrade to version 2022.1 in your system.

This is because there are a lot of bugs in version 2022.2 which seems to be causing the error in your system. The bugs will hopefully be fixed in the next update by the pytz technical team.

As an alternate solution, to quickly fix the issue, add the following lines to your Dockerfile:

RUN cp /usr/local/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aden /usr/local/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Hanoi && \
cp /usr/local/lib/python3.10/site-packages/tzdata/zoneinfo/Europe/Moscow /usr/local/lib/python3.10/site-packages/tzdata/zoneinfo/Europe/Kyiv

You can also run these lines in your command prompt to fix the error:

# upgrade pytz up to the latest pytz-2022.2.1
pip install pytz --upgrade
# upgarde tzdata up to tzdata-2022.2
pip install tzdata --upgrade

This will update or downgrade your dependencies to the version which is not showing errors.

Hope this should help you fix the error, “zoneinfo._common.ZoneInfoNotFoundError: ‘No time zone found with key Asia/Hanoi'”