How to properly create a pyinstaller hook, or maybe hidden import?

Hooks are files that specify additional actions when PyInstaller finds import statements.

If you add a hook-data.py file which contains a line hiddenimports = ['_proxy', 'utils', 'defs'], PyInstaller will check it to find additional imports when it sees import data.

You have to specify the path to the hook directory via --additional-hooks-dir (this is useful if you don’t want to mix your source code with compile-only files, and instead keep them in a separate directory).

The simpler solution is to use --hidden-import=modulename along with the PyInstaller script. It will add modulename as import statement silently.

Hooks are better if you want to specify which import needs what additional modules. --hidden-import is simpler as a one-shot or for debugging.

More info – https://pyinstaller.readthedocs.io/en/stable/hooks.html

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)