Traceback (most recent call last): File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module> File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 194, in _console_script_run run() File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 180, in run File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 429, in __init__ self.__postinit__() File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__ self.assemble() File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 590, in assemble priority_scripts.append(self.graph.add_script(script)) File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\depend\analysis.py", line 268, in add_script self._top_script_node = super().add_script(pathname) File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1345, in add_script contents = fp.read() + '\n' File "c:\users\administrator\appdata\local\programs\python\python38\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte
时间: 2023-07-30 22:08:56 浏览: 205
Python程序基础:Python中的异常.pptx
5星 · 资源好评率100%
这个错误是由于在读取文件时使用了错误的编码格式导致的。'utf-8' 编码格式不能解码字节 0x90,因此会引发 UnicodeDecodeError。为了解决这个问题,你可以尝试指定正确的编码格式来读取文件。
例如,如果你知道文件的编码格式是 'gbk',你可以使用以下代码来读取文件:
```python
with open('your_file.txt', 'r', encoding='gbk') as file:
contents = file.read()
```
请确保将 'your_file.txt' 替换为实际的文件路径和文件名。通过指定正确的编码格式,你应该能够成功读取文件并避免 UnicodeDecodeError。
阅读全文