简体   繁体   中英

PyInstaller - Hidden imports list

When trying to use the following script to add numerous hidden imports, pyinstaller returns an error saying:

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)

Is there a way to add a large amount of hidden imports using a script and not by hand? If it's any help, the warn.txt file's lines past line 16 all look like this (and the code produces the expected output when run in PyCharm, ie a list of module names): missing module named win32api - imported by pkg_resources._vendor.appdirs (delayed, conditional, optional)

Shortly after writing this question, I realized that I had overlooked a glaring issue.

The problem came from the hidden-imports line of the Analysis: hiddenimports=[stuff]

As you can see and as I'd have seen if I were less focused on the warnings, I put the list stuff between two square brackets, hence making the entire list but one element of the hidden imports.

If you ever have that problem, make sure to check this, it will save you a lot of trouble.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM