I created an application using the eel, pandas and holidays libraries. It retrieves the public holidays from my country and uses them to perform calculations for the report.
In the Pycharm interpreter, everything works as it should, the holidays are downloaded and the report is generated. After compiling the application to exe, when running the function responsible for generating the report, the error "no module named holidays.countries" is returned.
Code used to return holidays:
from datetime import datetime as dt
import holidays
holi = holidays.Poland(years=dt.today().year)
# I used this code -
# holidays.country_holidays('PL', years=dt.today().year)
# - before, but with the same result
Console command used to compile application
python -m eel main.py web --onefile --noconsole
More (maybe) useful informations:
- I use a computer in an organization with locked external repositories - I use the organization's repository.
- PIP version: 23.3.2, Holidays version: 0.41
I had similar problem with Tkinter. I was able to solve it with forced imports:
Try to modify this command to your needs (I do not have such library so I cannot do it).
Simply
--pathsshould lead to folder where libs are stored in environment. This will be actually the same path as I have.--hidden-importis used to force import libraries for the build which are missing right now.--resourceis used if you are missing any.dll(for example you encounter some exception after build with missing.dll)--collect-allshould force pyinstaller to include all packages from lib but it does not work as it should.These are optional paratemers for pyinstaller.
EDIT:
Note that python is not optimized for .exe building and most likely will never be.