Include multiple data files with pyinstaller

元气小坏坏 提交于 2020-02-22 07:27:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!