我感觉Pyinstaller的健壮性非常不好,总之我个人使用经常报出各种错误。
这次我遇到的错误是:
我在命令行中输入命令:
pyinstaller -F test.py
其中,test.py里面有中文字符,然后果不其然地报出了编码错误:
File "c:\python37\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 201: invalid continuation byte
对此,我查了很多博客和StackOverflow,得到的解决方案对我都没用。后来仔细想了想,感觉可能是文档本身编码的问题,遂解决:
- 右键→打开方式→记事本
- 点击左上角,文件→另存为
- 在下方以UTF-8的编码保存即可。问题解决。