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
pyinstaller
the first time.- Then later you can edit your
*.spec
file. - Then running
pyinstaller
will directly use your*.spec
file.
- 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:
source
anddestination
- 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-data
in command linepyinstaller -F --add-data "main.kv;." yourtarget.py
OR:
datas=
inyourtarget.spec
file, see following:
a = Analysis(...
datas = ["main.kv", "."],
...
)