【已解決】pyinstaller UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xce in position 110: invalid continuation byte


 

 

pyinstaller打包的時候,報錯如下:

File "D:\Python34\lib\site-packages\PyInstaller\hooks\hook-zmq.py", line 18, in <module>
hiddenimports.extend(collect_submodules('zmq.backend'))
File "D:\Python34\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 619, in collect_submodules
repr(pkg_dir), package))
File "D:\Python34\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 90, in exec_statement
return __exec_python_cmd(cmd)
File "D:\Python34\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 77, in __exec_python_cmd
txt = exec_python(*cmd, env=pp_env)
File "D:\Python34\lib\site-packages\PyInstaller\compat.py", line 549, in exec_python
return exec_command(*cmdargs, **kwargs)
File "D:\Python34\lib\site-packages\PyInstaller\compat.py", line 356, in exec_command
out = out.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 110: invalid continuation byte

這個錯誤,后來通過Google之后,解決方案如下:

https://stackoverflow.com/questions/47692960/error-when-using-pyinstaller-unicodedecodeerror-utf-8-codec-cant-decode-byt

其實就是:

修改D:\Python34\Lib\site-packages\PyInstaller\compat.py文件中

?
1
out = out.decode(encoding)

為:

?
1
out = out.decode(encoding, errors = 'ignore' )

然后再次運行腳本就不會報錯了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM