Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
826 views
in Technique[技术] by (71.8m points)

python - Using #-*- coding: utf-8 -*- does not remove "Non-ASCII character 'x90' in file hello.exe on line 1, but no encoding declared" error

I'm trying to convert a python file into an executable. So far so good. But when I try to run the executable I get the following error message:

SyntaxError: Non-ASCII character 'x90' in file hello.exe on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details"

This problem is widely documented, but using the given solution of adding

#-*- coding: utf-8 -*-

at the start of the line is not solving my issue.

I'm using Notepad++ editor and have even enforced the utf-8 encoding explicitly but to no avail.

Is there anything that I'm missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems you try to run your executable with

python hello.exe

while the point of creating an executable using py2exe is that you don't need to use the python interpreter anymore. So the error is actually not related to an encoding problem at all (though the error message might imply this) but just a consequence of calling python with a binary file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...