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

时间:2019-12-24 13:45:35

标签: python-3.x tensorflow pyinstaller h5py

我必须导入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:不可散列的类型:“列表”

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

1 个答案:

答案 0 :(得分:0)

我的坏人

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)