Search code examples
pythonpyqt5pyinstaller

Executables made with pyinstaller not working


I've been teaching myself Python3/API/PyQt5 and OOP for the last few weeks and I have finally made an app that works, yay! I've been working on Ubuntu 19 and the app works fine when I run it from the terminal. The problem is trying to compile it (correct term?) to make it an executable for Linux and Windows.

I used pyinstaller app.py --onefile -w --icon="app.ico" to make the files and I get no errors that I can see. I used Windows 10 to compire the exe.

Here is the problem: On Linux I get a "shared library" file that doesn't execute and on windows the exe is just broken. All I get is an error saying "this program cannot run on your system", or something similar to that.

This is a very simple, 1 script app with a PyQt5 GUI. I'm pretty new to all of this and this has by far been the hardest part. I've been stuck on this for days and I can't get it to work.

I can give you guys the app code if it will help, I just don't think I have enough rep to post links so it might have to be a code block.

I will be grateful for any help you guys can give as I'm out of ideas. Cheers!

Editing to add: windows 8.1 gives the error message "Error -3 from inflate: invalid block lengths" when the app.exe is run


Solution

  • After a lot more tinkering I finally have a working exe. I used -D to make a directory rather than the --onefile as that doesn't work. It makes an exe that doesn't work. Windows complains that it can't unpack the app. The exe that is inside the dist directory works on Windows 8.1 and Windows 10. Didn't test on Win 7.

    I also included the png and ico files and used a clean env with python 3.8 instead of my working env with 3.7 installed. I'm not sure if any of these things made a difference but if anyone else is looking for an answer, this might help.

    My final command: pyinstaller -y -D -w -i "FULL PATH TO ICON .ico" --add-data "FULL PATH TO IMAGE .png";"." "FULL PATH TO PY FILE /app.py"