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

前端 未结 2 746
囚心锁ツ
囚心锁ツ 2020-12-11 10:16

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:         


        
相关标签:
2条回答
  • 2020-12-11 10:57

    As someone else mentioned, you are running "python hello.exe" or "py hello.exe". So you are trying to run an executable with python.. Try just running the executable without python.

    You simply need to run "hello.exe".

    0 讨论(0)
  • 2020-12-11 11:11

    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.

    0 讨论(0)
提交回复
热议问题