If you want to use a bunch of hidden imports it's efficient to use in spec
file. on top of your spec file's content, make a list of required modules in something like all_libraries
, then define the hidden imports like the following example -
from PyInstaller.utils.hooks import collect_submodules
all_libraries = [
"altgraph",
"certifi",
"charset-normalizer",
"et-xmlfile",
"idna",
"Jinja2",
"macholib",
"packaging",
"pandas",
"pyparsing",
"PySide6",
"PySide6_Addons",
"PySide6_Essentials",
"python-dateutil",
"pytz",
"setuptools",
"shiboken6",
"six",
"tzdata",
"urllib3"
]
hidden_imports = []
for l in all_libraries:
hidden_imports += collect_submodules(l)
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[('./resources/data', 'resources/data'), ('./resources/icons', 'resources/icons')],
hiddenimports=hidden_imports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['resources/icons/icon.ico'],
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
app = BUNDLE(
coll,
name='main.app',
icon='./resources/icons/icon.ico',
bundle_identifier=None,
)