pyinstaller打包错误 UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 160:

注:我的博客原本在CSDN,现转到博客园,图片采用以前的图片,并没有盗图。

在将.py文件打包时,出现了下列错误

>>C:\Users\小呆\PycharmProjects\pycharm编程>pyinstaller -F C:\Users\小呆\PycharmProjects\pycharm编程\实验室笔试\火车票.py

>>Traceback (most recent call last):
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller-script.py", line 13, in <module>
    load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')()
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\__main__.py", line 94, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\building\build_main.py", line 791, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\building\build_main.py", line 737, in build
    exec(text, spec_namespace)
  File "<string>", line 29, in <module>
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\building\api.py", line 397, in __init__
    self.console, self.uac_admin, self.uac_uiaccess)
  File "C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1076, in create_manifest
    old_xml = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 160: illegal multibyte sequence

是由于C:\Users\小呆\AppData\Local\Programs\Python\Python36\lib\site-packages\PyInstaller\utils\win32文件夹下的winmanifest.py下读取文件编码格式的问题。

解:按错误代码的最后一个文件地址,在1075加一个'rb'。

posted @ 2019-03-30 11:20  丿小呆  阅读(930)  评论(0编辑  收藏  举报