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

问题描述 投票:0回答:1

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

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

python-3.x tensorflow pyinstaller h5py
1个回答
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)
© www.soinside.com 2019 - 2024. All rights reserved.