'FilenotFoundError with Pyinstaller : Some Modules are not included in application

I am trying to build a tkinter application with PyInstaller but I can't seem to resolve a missing module issue.

Here is (roughly) my file architecture :

📦app
 ┣ 📂summar-env
 ┃ ┣ 📂lib
 ┃ ┃ ┣ 📂python3.9
 ┃ ┃ ┃ ┣ 📂site-packages
 ┣ 📜my_app.py
 ┣ 📜abstractive_summarization_transformers.py
 ┣ 📜extractive_summarization_textrank.py
 ┣ 📜extractive_summarization_word_frequency.py
 ┗ 📜utils.py

I am working in a virtual environment summar-env in which everything works. my_app.py imports the modules in the same directory.

So I tried building the app directly with PyInstaller my_app.py in onedir mode. I got : FileNotFoundError: [Errno 2] No such file or directory: path/to/app/dist/evaluation_app/icecream/__version__.py' Even when adding the module with hidden-import=icecream"

So eventually I tried adding the missing modules directly to the spec file myhiddenimports=["icecream", "fr_core_news_sm"] as well as the path to the directory containing the modules in the environment pathex=['path/to/app/summar-env/lib/python3.9/site-packages'], before building directly from the spec file but to no avail.

I mention this module but I expect many other ones to be missing based on the list in the warn file in build directory (so I will need a way to add all those missing files)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source