pyinstaller生成的EXE文件在启动时崩溃

时间:2019-08-11 18:00:53

标签: python pyinstaller

我正在使用Python制作程序,并使用Pyinstaller来构建exe,但是每当我使用它时,它就会在启动时崩溃。

我正在尝试制作一个使用Python 3.7.4更改Windows桌面背景的程序。

这是我正在使用的代码:

def startvirus():
    ctypes.windll.user32.SystemParametersInfoW(20, 0, "\aliengray.png", 0)

这是我使用pyinstaller制作exe文件的代码:

pyinstaller --onefile C:\Pythonfiles\compress\proto.pyw --add-data C:\Pythonfiles\compress\aliengray.png;:

我将背景更改为Aliengray.png,但最终在启动时就崩溃了。

它显示此错误消息:

:\aliengray.jpg could not be extracted!
fopen: Invalid argument

1 个答案:

答案 0 :(得分:0)

问题必须出在图像.png文件的位置。 您指定了一个相对路径,因此当您运行EXE时,映像必须位于相对于EXE文件夹的相同路径中

如果要测试它,请尝试指定一个绝对路径,然后创建一个可执行文件。