zl程序教程

您现在的位置是:首页 >  其他

当前栏目

pytesseract 中文识别错误解决

2023-09-11 14:20:50 时间

  File "E:\odsoft\python\lib\subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "E:\odsoft\python\lib\subprocess.py", line 1179, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

text = pytesseract.image_to_string(Image.open("bb.jpg"),lang='chi_sim')
print(text)

出现错误解决方法

pytesseract.pytesseract.tesseract_cmd = 'E:/Program Files/Tesseract-OCR/tesseract.exe'

或者修改pytesseract.py中32行处:

#!/usr/bin/env python
import re
import shlex
import string
import subprocess
import sys
from contextlib import contextmanager
from csv import QUOTE_NONE
from distutils.version import LooseVersion
from errno import ENOENT
from functools import wraps
from glob import iglob
from io import BytesIO
from os import environ
from os import extsep
from os import linesep
from os import remove
from os.path import normcase
from os.path import normpath
from os.path import realpath
from pkgutil import find_loader
from tempfile import NamedTemporaryFile
from threading import Timer
from time import sleep

try:
    from PIL import Image
except ImportError:
    import Image


tesseract_cmd = 'E:/Program Files/Tesseract-OCR/tesseract.exe'