如何在规范文件中的pyinstaller中包含多个隐藏的导入

how to include multiple hidden imports in pyinstaller inside spec file

我必须导入 tensorflow_coreh5py

我做到了。

from PyInstaller.utils.hooks import collect_submodules

hiddenimports_tensorflow = collect_submodules('tensorflow_core')
hidden_imports_h5py = collect_submodules('h5py')


a = Analysis(['smile.py'],
             pathex=['D:\myfolder\myfile'],
             binaries=[],
             datas=[],
             hiddenimports=[hiddenimports_tensorflow,hidden_imports_h5py],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

hiddenimports=[hiddenimports_tensorflow,hidden_imports_h5py] 正在流行

TypeError: unhashable type: 'list'

如何在此处指定多个导入?

我的错

from PyInstaller.utils.hooks import collect_submodules

hiddenimports_tensorflow = collect_submodules('tensorflow_core')
hidden_imports_h5py = collect_submodules('h5py')

只需附加两个列表

all_hidden_imports = hiddenimports_tensorflow + hidden_imports_h5py
a = Analysis(['smile.py'],
             pathex=['D:\myfolder\myfile'],
             binaries=[],
             datas=[],
             hiddenimports=all_hidden_imports,
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)