注:我的博客原本在CSDN,现转到博客园,图片采用以前的图片,并没有盗图。
在将.py文件打包时,出现了下列错误
>>C:Users小呆PycharmProjectspycharm编程>pyinstaller -F C:Users小呆PycharmProjectspycharm编程实验室笔试火车票.py
>>Traceback (most recent call last):
File "C:Users小呆AppDataLocalProgramsPythonPython36Scriptspyinstaller-script.py", line 13, in <module>
load_entry_point('PyInstaller==3.3.1', 'console_scripts', 'pyinstaller')()
File "C:Users小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstaller\__main__.py", line 94, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:Users小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:Users小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstalleruildinguild_main.py", line 791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:Users小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstalleruildinguild_main.py", line 737, in build
exec(text, spec_namespace)
File "<string>", line 29, in <module>
File "C:Users小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstalleruildingapi.py", line 397, in __init__
self.console, self.uac_admin, self.uac_uiaccess)
File "C:Users小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstallerutilswin32winmanifest.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小呆AppDataLocalProgramsPythonPython36libsite-packagesPyInstallerutilswin32文件夹下的winmanifest.py下读取文件编码格式的问题。
解:按错误代码的最后一个文件地址,在1075加一个'rb'。