-1

I'm trying to convert my python file (py) that contains an mp3 file into an exe file using the command: pyinstaller --add-data "song.mp3" --onefile -w final_file.py in 'windows powershell'. So it showed this error:

pyinstaller: error: argument --add-data: invalid add_data_or_binary value: 'song.mp3'

Any idea how to fix this?

1 Answers1

1

The documentation clearly states that --add-data is for non-binary:

> --add-data <SRC;DEST or SRC:DEST>
> 
>     Additional non-binary files or folders to be added to the executable.
> The path separator is platform specific, os.pathsep (which
> is ; on Windows and : on most unix systems) is used. This option can
> be used multiple times.

use --add-binary instead

--add-binary <SRC;DEST or SRC:DEST>

    Additional binary files to be added to the executable.
    See the --add-data option for more details. This option can be used multiple times.

Note that if you include the file in the exe, you should use the correct path in the code in order to find the file once the bundle is used.

buran
  • 13,682
  • 10
  • 36
  • 61