0

My code (test.py) looks like this (simplified):

from app.utils import conversion

(code)

When I try to make an executable using PyInstaller, the .exe works when I import generic modules. However, I get the following error message when I use ''from app.utils import conversion'' at the beginning of my code:

ModuleNotFoundError: No module named 'app'

and the .exe won't run.

My project is structured this way (simplified):

project/app/test.py

project/app/utils/conversion.py

The instruction I put in the console is:

pyinstaller --onefile test.py

Any idea why and how to overcome this? Thanks!

  • Does this answer your question? [How to properly create a pyinstaller hook, or maybe hidden import?](https://stackoverflow.com/questions/27947639/how-to-properly-create-a-pyinstaller-hook-or-maybe-hidden-import) – buran Feb 10 '21 at 20:55
  • Also https://pyinstaller.readthedocs.io/en/stable/when-things-go-wrong.html#helping-pyinstaller-find-modules – buran Feb 10 '21 at 20:55

1 Answers1

0

Here is how I fixed my problem:

in the .spec file, added the missing app module in hiddenimports:

hiddenimports=["app"]

Then to compile the executable, I run the .spec file instead or the .py file.

pyinstaller --onefile test.spec