简体   繁体   中英

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?

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

You can try cxfreeze for creating the installer or executable package. Description of creating the setup file is given here . May be this could help you.

As @Hisham Karam already said in his comment to your question, you probably have not saved your file with the utf-8 encoding. Just adding # coding: utf-8 at the top of your python file is not enough, it also has to be encoded in utf-8 . There are many ways to check this, my preferred is to use Notepad++ :

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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