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

Locales not imported with PyInstaller #40

Open
alexitx opened this issue Jan 27, 2022 · 1 comment
Open

Locales not imported with PyInstaller #40

alexitx opened this issue Jan 27, 2022 · 1 comment

Comments

@alexitx
Copy link

alexitx commented Jan 27, 2022

Example:

import time
import timeago

timestamp = time.time() - 30
print(timeago.format(timestamp))

PyInstaller command:

$ pyinstaller -F -c --noupx -i NONE main.py

Output:

Traceback (most recent call last):
  File "timeago\locales\__init__.py", line 25, in timeago_template
ModuleNotFoundError: No module named 'timeago.locales.en'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    print(timeago.format(timestamp))
  File "timeago\__init__.py", line 80, in format
  File "timeago\locales\__init__.py", line 29, in timeago_template
[28604] Failed to execute script 'main' due to unhandled exception!

Python 3.10.1
PyInstaller 4.8
timeago 1.0.15

The PyInstaller documentation provides examples of how to add hooks for hidden imports. There is also an example package repo.

A temporary workaround is to add each locale module manually using --hidden-import 'timeago.locales.<locale>'

I haven't worked with PyInstaller hooks, but it looks easy to implement. I can try to make a PR if needed when I look at it further.

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

2 participants