python 3.6 下 PyInstaller 打包exe出错 UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position

用python3.6.6打包程序时遇到了如下错误

python 3.6 下 PyInstaller 打包exe出错 UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position

可以看到是old_xml = read.() 那里出了错,所以到winmanifest.py找到1076行,可以看到

python 3.6 下 PyInstaller 打包exe出错 UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position

将 with open(filename) as f : 变为 with open(filename,encoding="UTF-8") as f : 

如图:

python 3.6 下 PyInstaller 打包exe出错 UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position

再次打包exe

python 3.6 下 PyInstaller 打包exe出错 UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position

我们发现打包成功,UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position 198: illegal multibyte sequence 解决了