问题
I need to include a DLL AND a text file in a pyinstaller "onefile" executable. I can add just the DLL but if I try to specify both files, pyinstaller complains. I would rather use the command line options (rather than the spec file) - what's the correct format for multiple files?
http://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-data-files
http://pyinstaller.readthedocs.io/en/stable/usage.html#options-group-what-to-bundle-where-to-search
Tried a few things, e.g. pyinstaller: error: argument --add-data: invalid add_data_or_binary value: '/C/path1/my.dll;/c/path2/my.txt;.'
回答1:
The answer was in https://media.readthedocs.org/pdf/pyinstaller/cross-compiling/pyinstaller.pdf which indicates I can simply use the --add-data option multiple times!
回答2:
I do not know which syntax is necessary for the command line, but you can edit the generated spec to include the path to to data, where data is a list of tuples.
datas = [('/path/to/file', '/path/in/bundle').
(...) ]
So the spec might look as follows:
a = Analysis(['Frequency_Analysis_DataInput_Animation_cge.py'],
pathex=['C:\\Users\\mousavin\\Documents\\Analysis'],
binaries=[],
datas=[('/path/file1', '.'), (/path/file2, '.')],
...
and then build again with
pyinstaller script.spec
来源:https://stackoverflow.com/questions/47811131/include-multiple-data-files-with-pyinstaller