简体   繁体   English

将py和mp3文件转换成exe文件

[英]Converting py and mp3 files to exe file

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'.我正在尝试使用以下命令将包含 mp3 文件的 python 文件 (py) 转换为 exe 文件: 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' pyinstaller: 错误: 参数 --add-data: 无效的 add_data_or_binary 值: 'song.mp3'

Any idea how to fix this?知道如何解决这个问题吗?

The documentation clearly states that --add-data is for non-binary: 文档明确指出--add-data适用于非二进制:

> --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代替

--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.请注意,如果您将文件包含在 exe 中,则应在代码中使用正确的路径,以便在使用捆绑包后找到该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM