Pyinstaller adding data files

staos2 picture staos2 · Jan 26, 2017 · Viewed 50.8k times · Source

I'm struggling with pyinstaller. Whenever I build this specific script with a kivy GUI and a .kv file, and run the .exe after the build, I get a fatal error:

IOError: [Errno 2] No such file or directory: 'main.kv'

I've tried adding the .kv file, as well as a mdb and dsn file (for pypyodbc) using --add-data, but I get an error: unrecognized arguments: --add-data'main.kv'. (There were more --add-data arguments for the other files mentioned.)

Are there any solutions for this or maybe alternative methods?

Answer

Anson Chan picture Anson Chan · May 17, 2017

If you check pyinstaller -h for help, you can find --add-data option works like this [--add-data <SRC;DEST or SRC:DEST>]. So in your case try

pyinstaller -F --add-data "main.kv;main.kv" yourtarget.py