python Gooey打包exe报错UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xc4 in position 0: invalid c

Gooey打包exe方法跟普通打包方式不一样,需要修改源代码,看下打包后的exe程序运行的报错信息:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte
File "gooey\gui\processor.py", line 93, in _extract_progress UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 10: invalid continuation byte
【分析】
一看报错就发现是编码问题,所以想着要从编码入手。
【解决方案】
File "gooey\gui\processor.py", line 79, in _forward_stdout   ---此函数需要修改
              import chardet
              enc1=chardet.detect(line)
              pub.send_message(events.CONSOLE_UPDATE,
                                 #msg=line.decode(self.encoding))
                                 msg=line.decode(enc1['encoding']))----此句需修改

File "gooey\gui\processor.py", line 93, in _extract_progress
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 10: invalid continuation byte
此函数一样报错 _extract_progress,修改成如下:
        import chardet
        enc1 = chardet.detect(text)

        #find = partial(re.search, string=text.strip().decode(self.encoding))
        find = partial(re.search, string=text.strip().decode(enc1['encoding']))---此句需修改

更改以上gooey源代码后,再用pyinstaller打包成exe文件就可以正常运行了。

【发文章不易,请各位多多支持、点赞!】

你可能感兴趣的:(python,python)