As others (@Anson Chan, @schlimmchen) have said:
If you want to add some extra files, you should use Adding Data Files.
Two ways to implement
- Command Line: add parameter to
--add-data - Spec file: add parameter to
datas=- Generated when running
pyinstallerthe first time.- Then later you can edit your
*.specfile. - Then running
pyinstallerwill directly use your*.specfile.
- Then later you can edit your
- Generated when running
Parameter Logic
Parameter in --add-data or datas=:
--add-data:- format:
{source}{os_separator}{destination}os_separator:- Windows:
; - Mac/Linux/Unix:
:
- Windows:
sourceanddestination- Logic:
source: path to single or multiple files, supporting glob syntax. Tells PyInstaller where to find the file(s).destination
file or files: destination folder which will contain your source files at run time.
* NOTE: NOT the destination file name.- folder: destination folder path, which is RELATIVE to the destination root, NOT an absolute path.
- Logic:
- Examples:
- Single file:
'src/README.txt:.' - multiple files:
'/mygame/sfx/*.mp3:sfx' - folder:
'/mygame/data:data'
- Single file:
- format:
datas=- Format: list or tuple.
- Examples: see the following.
added_files = [
( 'src/README.txt', '.' ),
( '/mygame/data', 'data' ),
( '/mygame/sfx/*.mp3', 'sfx' )
]
a = Analysis(...
datas = added_files,
...
)
Your case
For your (Windows OS) here is:
--add-datain command linepyinstaller -F --add-data "main.kv;." yourtarget.py
OR:
datas=inyourtarget.specfile, see following:
a = Analysis(...
datas = ["main.kv", "."],
...
)