From pyinstaller documentation
hiddenimports
A list of modules names (relative or absolute) the module imports in some untrackable way.
Some imported Python are not available when statically analyzing your program. for example, your code could create a module name to import using Python code, and then import that module. In this case, pyinstaller will not be able to work during code analysis, what is the name of the module to import. If you know in advance, then you can say that pyinstaller unconditionally includes these modules.
Hooks are a way for you to link a set of hidden imports and other parameters related to finding modules. The hooks are called hook-<module>.py , where the module is the full name of the module. e.g. hook-xml.dom.py . If your code does import xml.dom , then the contents of the script hook are read to include any hidden imports specific to xml.dom .
If you create your own module and require hidden imports, you can create a hook script with the corresponding hidden import parameters and save it in the PyInstaller hook directory. The next time you use PyInstaller to freeze a program that imports your module, it will automatically find your hook file and pull out the necessary hidden import, without worrying about what hidden imports are for your module.
The documentation has more information on how this all works, but hopefully this provides additional background information.
source share