Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System timezones or installed tzdata may not cover pytz.common_timezones #85

Open
paulocoutinhox opened this issue Mar 11, 2022 · 5 comments

Comments

@paulocoutinhox
Copy link

Hi,

Im getting this error:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paulo/Developer/workspaces/python/pyaa/manage.py", line 22, in <module>
    main()
  File "/Users/paulo/Developer/workspaces/python/pyaa/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "/usr/local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.9/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 304, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/paulo/Developer/workspaces/python/pyaa/customer/models.py", line 12, in <module>
    from timezone_field import TimeZoneField
  File "/usr/local/lib/python3.9/site-packages/timezone_field/__init__.py", line 1, in <module>
    from timezone_field.fields import TimeZoneField
  File "/usr/local/lib/python3.9/site-packages/timezone_field/fields.py", line 11, in <module>
    class TimeZoneField(models.Field):
  File "/usr/local/lib/python3.9/site-packages/timezone_field/fields.py", line 41, in TimeZoneField
    default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
  File "/usr/local/lib/python3.9/site-packages/timezone_field/fields.py", line 41, in <listcomp>
    default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
  File "/usr/local/Cellar/[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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 Pacific/Kanton'

Thanks.

@paulocoutinhox
Copy link
Author

I need install package tzdata to make it work.

It is really necessary?

@mfogel
Copy link
Owner

mfogel commented Mar 17, 2022

Hi @paulocoutinhox, what version of django are you running and on what platform?

It looks like django 4.X on windows should be installing tzdata by default. So I'm guessing you're on django 3.X on windows? Is that correct? Thanks.

@paulocoutinhox
Copy link
Author

Im using latest django 4 on macos.

@mfogel
Copy link
Owner

mfogel commented Mar 17, 2022

Ok thanks

It looks like the timezone which is causing the problem is Pacific/Kanton was added to the IANA database in september 2021. So it makes sense that the system default list of timezones doesn't include it yet.

I'm hesitant to add a direct dependency on tzdata to this package because both python stdlib (via zoneinfo) and django choose not to do so. Let me mull it over. Perhaps we should push for django to remove the sys_platform == 'win32' part of this line.

@garw
Copy link

garw commented May 27, 2022

I just encountered the same issue with python 3.9 on debian bullseyse with django 3.x. I now manually fixed pytz==2021.1 for my setup to get around this.

@mfogel mfogel changed the title Problems when use this field on Django 4 System or installed copy of tzdata may not cover all of pytz.common_timezones Jun 18, 2023
@mfogel mfogel changed the title System or installed copy of tzdata may not cover all of pytz.common_timezones System timezones or installed tzdata may not cover pytz.common_timezones Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants