【问题标题】:PyInstaller - Hidden imports listPyInstaller - 隐藏的导入列表
【发布时间】:2020-09-04 02:13:13
【问题描述】:

当尝试使用以下脚本添加大量隐藏导入时,pyinstaller 返回错误:

TypeError: unhashable type: 'list'

stuff = []

with open("warn.txt", 'r') as f:
    lines = f.readlines()

for i in range(16, len(lines)):
    content = (lines[i].split('-', 1))[0][21:-1]
    if content != '':
        if content[0] == '\'':
            content = content[1:-1]
        stuff.append(content)

有没有办法使用脚本而不是手动添加大量隐藏导入? 如果有任何帮助,warn.txt 文件在第 16 行之后的行看起来都像这样(并且代码在 PyCharm 中运行时会产生预期的输出,即模块名称列表): missing module named win32api - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional)

【问题讨论】:

    标签: python python-3.x build pyinstaller


    【解决方案1】:

    写完这个问题后不久,我意识到我忽略了一个明显的问题。

    问题来自分析的hidden-imports 行: hiddenimports=[stuff]

    如您所见,如果我不那么关注警告,我会看到,我将列表 stuff 放在两个方括号之间,从而使整个列表成为隐藏导入的一个元素。

    如果您遇到过这个问题,请务必检查一下,它会为您省去很多麻烦。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-05
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 2019-11-17
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      相关资源
      最近更新 更多