ChaosJulien / XiaoYuanKouSuan_Auto

用于小猿口算的基于Python的自动答题工具
GNU General Public License v3.0
650 stars 76 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 27: invalid start byte 编码问题 #36

Open Found-404 opened 3 weeks ago

Found-404 commented 3 weeks ago

Traceback (most recent call last): File "E:\xiaoyuankousuan\mainTwo.py", line 102, in main() # 启动主程序

  File "E:\xiaoyuankousuan\mainTwo.py", line 95, in main
    numbers = recognize_numbers(image)  # 从截取的图像中识别数字
  File "E:\xiaoyuankousuan\mainTwo.py", line 25, in recognize_numbers
    text = pytesseract.image_to_string(thresh, config='--psm 6')
  File "E:\stable-diffusion-webui\pyenv\py3.13\Lib\site-packages\pytesseract\pytesseract.py", line 486, in image_to_string
    return {
           ~
    ...<2 lines>...
        Output.STRING: lambda: run_and_get_output(*args),
}[output_type]()
~~~~~~~~~~~~~~^^

File "E:\stable-diffusion-webui\pyenv\py3.13\Lib\site-packages\pytesseract\pytesseract.py", line 489, in Output.STRING: lambda: run_and_get_output(*args),


  File "E:\stable-diffusion-webui\pyenv\py3.13\Lib\site-packages\pytesseract\pytesseract.py", line 352, in run_and_get_output
    run_tesseract(**kwargs)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "E:\stable-diffusion-webui\pyenv\py3.13\Lib\site-packages\pytesseract\pytesseract.py", line 284, in run_tesseract
    raise TesseractError(proc.returncode, get_errors(error_string))
                                          ~~~~~~~~~~^^^^^^^^^^^^^^
  File "E:\stable-diffusion-webui\pyenv\py3.13\Lib\site-packages\pytesseract\pytesseract.py", line 172, in get_errors
    line for line in error_string.decode(DEFAULT_ENCODING).splitlines()
                     ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 27: invalid start byte
GalacticDevOps commented 3 weeks ago

加上 encoding=utf-8就可以了