前幾天,我在執行Python 3版的py2exe出現
"UnicodeDecodeError: 'cp950' codec can't decode bytes"
錯誤,就上網Google一下可能的解法:
notepad或notepad++的utf-8編碼文件: open('filename', encoding = 'utf-8-sig')
notepad++的utf-8 without BOM文件: open('filename', encoding = 'utf8')
最後我把C:\Python34\Lib\site-packages\py2exe\runtime.py,
第577 line:
從原本
with open(target.script, "U") as script_file:
改成
with open(target.script, "U", encoding = 'utf-8-sig') as script_file:
就可以正常執行
"UnicodeDecodeError: 'cp950' codec can't decode bytes"
錯誤,就上網Google一下可能的解法:
notepad或notepad++的utf-8編碼文件: open('filename', encoding = 'utf-8-sig')
notepad++的utf-8 without BOM文件: open('filename', encoding = 'utf8')
最後我把C:\Python34\Lib\site-packages\py2exe\runtime.py,
第577 line:
從原本
with open(target.script, "U") as script_file:
改成
with open(target.script, "U", encoding = 'utf-8-sig') as script_file:
就可以正常執行
py -3.4 -m py2exe myscript.py -W mysetup.py ... edit myssetup.py py -3.4 mysetup.py py2exe
沒有留言:
張貼留言