I have a GUI application that will not package to an exe with pyinstaller. When I run pyinstaller main.py --onefile --windowed I get the following error.
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'pendulum.locales'
I updated pendulum from 1.4 to 2.0.5 and then the exe built fine. However this would not run. I reran pyinstaller without the --windowed flag and could then see the ORM I'm using (orator) is not compatible with > 1.4 pendulum and could not import Pendulum form pendulum.
from pendulum import Pendulum, Date
ImportError: cannot import name 'Pendulum' from 'pendulum' (C:\Users\Paul\PycharmProjects\JobsV10\venv\lib\site-packages\pendulum\__init__.py)
I have tried following posts that change the hooks in pyinstaller but none of these work.
https://github.com/pyinstaller/pyinstaller/issues/3528
I don't really want to remove orator as I use Laravel a lot and orator is close to the excellent Eloquent which I am familiar with. Is there a work around to get pyinstaller to work woth pendulum 1.4?
Changing
datas = collect_data_files("pendulum.locales", include_py_files=True)
in the Site Packages/Pyinstalller/hooks/hook-pendulum.py to
datas = collect_data_files("pendulum", include_py_files=True)
seems to have done the trick.
Not going to mark this as the answer yet as I'm not sure if this will cause issues down the line.
This has fixed my problem and has been in production for over 50 days with no issues so I am now going to mark it as answered. Although this fixed my issue, removing the '.locales' may break something in certain circumstances so always keep this in mind.