python-3.x - 如何在 pyinstaller 的 spec 文件内包含多个隐藏导入

标签 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: 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)

关于python-3.x - 如何在 pyinstaller 的 spec 文件内包含多个隐藏导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59469743/

相关文章:

python - couchbase 已安装,但仍然出现导入错误(Pyinstaller)

css - Beautiful Soup 无法区分 CSS 类

python - 将日期时间字符串快速转换为秒 (Python3)

python - 每个时期隐藏层的输出并将其存储在 keras 的列表中?

python - tf.variable_scope 中的重用选项如何工作?

python - pyinstaller 和 matplotlib 超出最大递归深度

python - Python 中的线程安全警告

python - 你如何使用嵌套的 for 循环在 python 中打印出以下模式?

c++ - 如何在 C++ 中填充张量

python - Pyinstaller Jinja2 TemplateNotFound