[英]Can't open the desktop app created with PyInstaller
I created a PyIinstaller file from a .py
file.我从
.py
文件创建了一个 PyIinstaller 文件。 In this file, I've got files with the .ui
extension created using PyQt4.在这个文件中,我有使用 PyQt4 创建的扩展名为
.ui
文件。 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.在原来的
.py
文件中,我使用的是 UTF-8 编码,但是这个错误显示了一个 ASCII 问题。
How can I fix this error?我该如何解决这个错误?
This is a Python traceback, but the first line is showing an exe file :这是一个 Python 回溯,但第一行显示了一个exe 文件:
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.你不能用 Python 运行 exe 文件。 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.
事实上,使用 PyInstaller 之类的工具的全部意义在于,您甚至不需要安装 Python 来运行程序。 You have created a self-contained executable , so just run it directly, like this:
你已经创建了一个自包含的可执行文件,所以直接运行它,像这样:
C:\Users\Flosh\Desktop\dist\ProgramNew\New.exe
As @Hisham Karam already said in his comment to your question, you probably have not saved your file with the utf-8 encoding.正如@Hisham Karam 在他对您的问题的评论中所说的那样,您可能没有使用 utf-8 编码保存您的文件。 Just adding
# coding: utf-8
at the top of your python file is not enough, it also has to be encoded in utf-8 .仅在 python 文件的顶部添加
# coding: utf-8
是不够的,它还必须以 utf-8 编码。 There are many ways to check this, my preferred is to use Notepad++ :有很多方法可以检查这一点,我更喜欢使用Notepad++ :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.