Using --onefile with a .spec in PyInstaller

You can add the extra file on the command line instead of editing the spec file:

pyinstaller --onefile --add-data <SRC;DEST or SRC:DEST> yourfile.py

Otherwise, make sure in the spec file there is no collect step:

"In one-file mode, there is no call to COLLECT, and the EXE instance receives all of the scripts, modules and binaries."

https://pyinstaller.readthedocs.io/en/stable/usage.html for more info on command line flags.

This also may offer some insight if problems persist: Bundling data files with PyInstaller (--onefile)


Use pyi-makespec --onefile yourprogram.py to generate a sample spec file for onefile mode.

https://pyinstaller.readthedocs.io/en/stable/man/pyi-makespec.html


There is no COLLECT call, and the EXE call is different. Example:

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='main',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )