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

tzdata requirement missing for docker-compose #529

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mavericm1
Copy link

docker-compose up -d

Fails to start because tzdata is missing

I've added tzdata to the requirements/defaults.txt but i'm unsure if this is this is the appropriate requirements file it has other tz related packages so i would assume so. Adding tzinfo fixes the issue and its able to start cleanly.

django_1 | ModuleNotFoundError: No module named 'tzdata'

django_1 | # wait-for-it postgres:5432
django_1 | wait-for-it: waiting 15 seconds for postgres:5432
django_1 | wait-for-it: postgres:5432 is available after 1 seconds
django_1 | # python3 manage.py migrate
django_1 | Traceback (most recent call last):
django_1 | File "/root/.local/lib/python3.8/site-packages/backports/zoneinfo/_common.py", line 15, in load_tzdata
django_1 | return importlib_resources.open_binary(package_name, resource_name)
django_1 | File "/usr/local/lib/python3.8/importlib/resources.py", line 88, in open_binary
django_1 | package = _get_package(package)
django_1 | File "/usr/local/lib/python3.8/importlib/resources.py", line 47, in _get_package
django_1 | module = import_module(package)
django_1 | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 961, in _find_and_load_unlocked
django_1 | File "", line 219, in _call_with_frames_removed
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 961, in _find_and_load_unlocked
django_1 | File "", line 219, in _call_with_frames_removed
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 973, in _find_and_load_unlocked
django_1 | ModuleNotFoundError: No module named 'tzdata'
django_1 |
django_1 | During handling of the above exception, another exception occurred:
django_1 |
django_1 | Traceback (most recent call last):
django_1 | File "manage.py", line 22, in
django_1 | main()
django_1 | File "manage.py", line 18, in main
django_1 | execute_from_command_line(sys.argv)
django_1 | File "/root/.local/lib/python3.8/site-packages/django/core/management/init.py", line 446, in execute_from_command_line
django_1 | utility.execute()
django_1 | File "/root/.local/lib/python3.8/site-packages/django/core/management/init.py", line 420, in execute
django_1 | django.setup()
django_1 | File "/root/.local/lib/python3.8/site-packages/django/init.py", line 24, in setup
django_1 | apps.populate(settings.INSTALLED_APPS)
django_1 | File "/root/.local/lib/python3.8/site-packages/django/apps/registry.py", line 116, in populate
django_1 | app_config.import_models()
django_1 | File "/root/.local/lib/python3.8/site-packages/django/apps/config.py", line 304, in import_models
django_1 | self.models_module = import_module(models_module_name)
django_1 | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 975, in _find_and_load_unlocked
django_1 | File "", line 671, in _load_unlocked
django_1 | File "", line 843, in exec_module
django_1 | File "", line 219, in _call_with_frames_removed
django_1 | File "/app/django_celery_beat/models.py", line 4, in
django_1 | import timezone_field
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/init.py", line 1, in
django_1 | from timezone_field.fields import TimeZoneField
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/fields.py", line 11, in
django_1 | class TimeZoneField(models.Field):
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/fields.py", line 41, in TimeZoneField
django_1 | default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/fields.py", line 41, in
django_1 | default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
django_1 | File "/root/.local/lib/python3.8/site-packages/backports/zoneinfo/_common.py", line 27, in load_tzdata
django_1 | raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
django_1 | backports.zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Pacific/Kanton'
django_1 | # wait-for-it postgres:5432
django_1 | wait-for-it: waiting 15 seconds for postgres:5432
django_1 | wait-for-it: postgres:5432 is available after 0 seconds
django_1 | # python3 manage.py migrate
django_1 | Traceback (most recent call last):
django_1 | File "/root/.local/lib/python3.8/site-packages/backports/zoneinfo/_common.py", line 15, in load_tzdata
django_1 | return importlib_resources.open_binary(package_name, resource_name)
django_1 | File "/usr/local/lib/python3.8/importlib/resources.py", line 88, in open_binary
django_1 | package = _get_package(package)
django_1 | File "/usr/local/lib/python3.8/importlib/resources.py", line 47, in _get_package
django_1 | module = import_module(package)
django_1 | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 961, in _find_and_load_unlocked
django_1 | File "", line 219, in _call_with_frames_removed
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 961, in _find_and_load_unlocked
django_1 | File "", line 219, in _call_with_frames_removed
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 973, in _find_and_load_unlocked
django_1 | ModuleNotFoundError: No module named 'tzdata'
django_1 |
django_1 | During handling of the above exception, another exception occurred:
django_1 |
django_1 | Traceback (most recent call last):
django_1 | File "manage.py", line 22, in
django_1 | main()
django_1 | File "manage.py", line 18, in main
django_1 | execute_from_command_line(sys.argv)
django_1 | File "/root/.local/lib/python3.8/site-packages/django/core/management/init.py", line 446, in execute_from_command_line
django_1 | utility.execute()
django_1 | File "/root/.local/lib/python3.8/site-packages/django/core/management/init.py", line 420, in execute
django_1 | django.setup()
django_1 | File "/root/.local/lib/python3.8/site-packages/django/init.py", line 24, in setup
django_1 | apps.populate(settings.INSTALLED_APPS)
django_1 | File "/root/.local/lib/python3.8/site-packages/django/apps/registry.py", line 116, in populate
django_1 | app_config.import_models()
django_1 | File "/root/.local/lib/python3.8/site-packages/django/apps/config.py", line 304, in import_models
django_1 | self.models_module = import_module(models_module_name)
django_1 | File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "", line 1014, in _gcd_import
django_1 | File "", line 991, in _find_and_load
django_1 | File "", line 975, in _find_and_load_unlocked
django_1 | File "", line 671, in _load_unlocked
django_1 | File "", line 843, in exec_module
django_1 | File "", line 219, in _call_with_frames_removed
django_1 | File "/app/django_celery_beat/models.py", line 4, in
django_1 | import timezone_field
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/init.py", line 1, in
django_1 | from timezone_field.fields import TimeZoneField
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/fields.py", line 11, in
django_1 | class TimeZoneField(models.Field):
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/fields.py", line 41, in TimeZoneField
django_1 | default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
django_1 | File "/root/.local/lib/python3.8/site-packages/django_timezone_field-5.0-py3.8.egg/timezone_field/fields.py", line 41, in
django_1 | default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
django_1 | File "/root/.local/lib/python3.8/site-packages/backports/zoneinfo/_common.py", line 27, in load_tzdata
django_1 | raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
django_1 | backports.zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Pacific/Kanton'

@@ -1,3 +1,4 @@
celery>=5.2.3,<6.0
django-timezone-field>=4.2.3
python-crontab>=2.3.4
tzdata>=2022.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

django 4.0 switched to zoneinfo that might be the cause, does adding this package make the docker build happy?

Copy link
Author

@mavericm1 mavericm1 Apr 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zoneinfo requires timezone data either installed as a os package in which case isn't installed as a os package currently via the dockerfiles nor is it part of the base image of python:3.8-slim or by installing the tzdata python package. Documentation below.

https://docs.python.org/3/library/zoneinfo.html#data-sources

(https://docs.python.org/3/library/zoneinfo.html#data-sources)Data sources The zoneinfo module does not directly provide time zone data, and instead pulls time zone information from the system time zone database or the first-party PyPI package [tzdata](https://pypi.org/project/tzdata/), if available. Some systems, including notably Windows systems, do not have an IANA database available, and so for projects targeting cross-platform compatibility that require time zone data, it is recommended to declare a dependency on tzdata. If neither system data nor tzdata are available, all calls to [ZoneInfo](https://docs.python.org/3/library/zoneinfo.html#zoneinfo.ZoneInfo) will raise [ZoneInfoNotFoundError](https://docs.python.org/3/library/zoneinfo.html#zoneinfo.ZoneInfoNotFoundError).

@auvipy
Copy link
Member

auvipy commented Apr 11, 2022

@diegocastrum can you review this

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

Successfully merging this pull request may close these issues.

2 participants