简体   繁体   English

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

[英]EXE file generated with pyinstaller crashes on start

I'm making a program using Python and using Pyinstaller to build the exe, but whenever I use it it crashes on launch. 我正在使用Python制作程序,并使用Pyinstaller生成exe,但是每当我使用它时,它在启动时都会崩溃。

I'm trying to make a program that changes the windows desktop background using Python 3.7.4. 我正在尝试制作一个使用Python 3.7.4更改Windows桌面背景的程序。

This is the code I'm using: 这是我正在使用的代码:

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

And this is the code I'm using to make the exe file using pyinstaller: 这是我使用pyinstaller制作exe文件的代码:

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

I made it to change the background to aliengray.png, but it ends up just crashing on start. 我将背景更改为Aliengray.png,但最终刚开始崩溃。

It gives this error message: 它给出此错误信息:

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

The problem must be with the location of the image .png file. 问题必须出在图像.png文件的位置。 You specify a relative path, so when you run your EXE the image has to be in the same path relative to the folder of the EXE 您指定了相对路径,因此在运行EXE时,映像必须位于相对于EXE文件夹的相同路径中。

If you want to test it, try to specify an absolute path and then create an executable. 如果要测试它,请尝试指定绝对路径,然后创建一个可执行文件。

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

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