在Windows 10下尝试将python文件转换为exe时遇到了Traceback:UnicodeDecodeError:'gbk'编解码器无法解码位置180的字节0xae:非法的多字节序列 请帮助,谢谢。
这是test.spec文件:
# -*- mode: python -*-
import sys
sys.setrecursionlimit(10000000)
block_cipher = None
a = Analysis(['test.py'],
pathex=['C:\\Users\\User\\Desktop\\test'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='test',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
这是回溯日志:
Traceback (most recent call last):
File "c:\users\user\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\user\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\User\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\users\user\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\user\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\user\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\user\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 33, in <module>
File "c:\users\user\anaconda3\lib\site-packages\PyInstaller\building\api.py", line 410, in __init__
self.console, self.uac_admin, self.uac_uiaccess)
File "c:\users\user\anaconda3\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 1076, in create_manifest
old_xml = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 180: illegal multibyte sequence
以下是参考链接:
UnicodeDecodeError:'gbk' codec can't decode byte 0x80 in position 0 illegal multibyte sequence
答案 0 :(得分:0)
只需将Python文件名从中文更改为英语即可。