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

Missing hook for pytz_deprecation_shim package #344

Closed
cbdj opened this issue Nov 4, 2021 · 2 comments
Closed

Missing hook for pytz_deprecation_shim package #344

cbdj opened this issue Nov 4, 2021 · 2 comments
Labels

Comments

@cbdj
Copy link

cbdj commented Nov 4, 2021

Which library is the hook for?

pytz_deprecation_shim used by tzlocal which is used by apscheduler

Have you gotten the library to work with pyinstaller?

Yes.
python 3.7.8 with tzlocal package installed (pip install tzlocal)
main.py:

from tzlocal import get_localzone
print(get_localzone())
  • python main.py runs OK

  • pyinstaller --onefile main.py
    ./main.exe runs KO with exception:

    Traceback (most recent call last):
      File "backports\zoneinfo\_common.py", line 15, in load_tzdata
      File "importlib\resources.py", line 88, in open_binary
      File "importlib\resources.py", line 47, in _get_package
      File "importlib\__init__.py", line 127, in import_module
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'tzdata'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "pytz_deprecation_shim\_impl.py", line 39, in timezone
      File "pytz_deprecation_shim\_compat_py3.py", line 16, in get_timezone
      File "backports\zoneinfo\_common.py", line 27, in load_tzdata
    backports.zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Europe/Paris'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "main.py", line 2, in <module>
        print(get_localzone())
      File "tzlocal\win32.py", line 119, in get_localzone
      File "pytz_deprecation_shim\_impl.py", line 41, in timezone
    pytz_deprecation_shim._exceptions.UnknownTimeZoneError: 'Europe/Paris'
    [26796] Failed to execute script 'main' due to unhandled exception!
    
  • pyinstaller --onefile main.py --collect-all tzlocal --collect-all tzdata
    ./main.exe runs OK

  • pyinstaller --onefile main.py --additional-hooks-dir hooks
    ./main.exe runs OK with hooks/ folder containing:
    hook-pytz_deprecation_shim.py

    # hidden reference to tzdata
    from PyInstaller.utils.hooks import copy_metadata,collect_data_files
    datas = []
    datas += copy_metadata('tzdata')
    datas += collect_data_files('tzdata', True)
    
@cbdj cbdj added good first issue Good for newcomers hook-request labels Nov 4, 2021
@rokm
Copy link
Member

rokm commented Nov 4, 2021

Should be already fixed by #339.

@cbdj
Copy link
Author

cbdj commented Nov 4, 2021

Indeed

@cbdj cbdj closed this as completed Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants