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;.'
In order to add data multiple files into your EXE file using pyinstaller, the best way is to add the list of files into your application's spec file. This line adds all the files inside assets folder inside your application's assets folder.
PyInstaller can bundle your script and all its dependencies into a single executable named myscript ( myscript.exe in Windows). The advantage is that your users get something they understand, a single executable to launch.
In PyInstaller it is easy to create one exe, By default both create a bunch of exes & dlls. In py2exe its easier to embed manifest file in exe, useful for run as administrator mode in windows vista and beyond. Pyinstaller is modular and has a feature of hooks to include files in the build that you like.
PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller reads a Python script written by you.
pathex is an optional list of paths to be searched before sys.path. Source: https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/building/build_main.py#L123. The spec file is actually executable Python code. PyInstaller builds the app by executing the contents of the spec file.
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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With