Search code examples
pythonencodingsyntax-errorpyqt4pyinstaller

Can't open the desktop app created with PyInstaller


I created a PyIinstaller file from a .py file. In this file, I've got files with the .ui extension created using PyQt4. But when I try to execute the file created, it shows this error:

File "C:\Users\Flosh\Desktop\dist\ProgramNew\New.exe", line 1
SyntaxError: Non-ASCII character '\x90' in file C:\Users\Flosh\Desktop\dist\ProgramNew\New.exe on line 1, 
but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

In the original .py file, I use the UTF-8 encoding, but this error shows an ASCII problem.

How can I fix this error?


Solution

  • This is a Python traceback, but the first line is showing an exe file:

    File "C:\Users\Flosh\Desktop\dist\ProgramNew\New.exe", line 1
    

    which suggests you must be trying to run the application like this:

    python C:\Users\Flosh\Desktop\dist\ProgramNew\New.exe
    

    You cannot run exe files with Python. Indeed, the whole point of using tools like PyInstaller is that you don't even need to have Python installed in order to run the program. You have created a self-contained executable, so just run it directly, like this:

    C:\Users\Flosh\Desktop\dist\ProgramNew\New.exe