3

I am developing a PyQT based Windows Application. I have lot of folders with many python files. But when I try to create an executable with the pyinstaller python package,the dependencies of the files in the other folders could not be resolved. For Simplicity, this is my folder structure

gui
    -gui.py
    -main.py
libs
    -testlibs.py
utility
    -folderstructure.py

I have used the command pyinstaller main.py --onefile The problem is gui.py imports utility.folderstructure which couldnot be resolved after the exe is generated.

The exe is throwing execption that utility cannot be found.

I have added addition hook directory option. In that I have added a file named hook-gui.py with content hiddenimports=[".utility.folderstructure.*"] Now my folderstructure is

gui
    -gui.py
    -main.py
    -hook-gui.py
libs
    -testlibs.py
utility
    -folderstructure.py

But while running the command pyinstaller ----additional-hooks-dir=. main.py --onefile

INFO: Loading module hook hook-gui.py... WARNING: Hidden import .utility.folderstructure.* not found! This particular error pops up.

Could you tell where I am wrong?

1 Answer 1

2

Normally I would use a layout similar to:

-main.py
-gui
    -init.py
    -gui.py
    -hook-gui.py
-libs
    -init.py
    -testlibs.py
-utility
    -init.py
    -folderstructure.py

Pyinstaller has always found the modules for me in this style layout.

You're just going to have to adjust some imports.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, i have added --path="< Import path > " while running the pyinstaller and it resolved my issue. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.