简体   繁体   中英

How can I import all my python files in multiple folder hierarchy into a single pyinstaller executable?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM