gpt4 book ai didi

python - 无法使用pytesseract从图像中获取文本

转载 作者:太空宇宙 更新时间:2023-11-03 15:53:32 26 4
gpt4 key购买 nike

当我使用下面的代码时,得到的错误是“WindowsError:[Error 2] The system cannot find the file specified”。请帮我从图片中获取文字。

from pytesseract import image_to_string
from PIL import Image

print image_to_string(Image.open(r'D:\\name.jpg'),lang='eng')

错误:

WindowsError Traceback (most recent call last) in () 2 from PIL import Image 3 ----> 4 print image_to_string(Image.open(r'D:\name.jpg'),lang='eng')

C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.pyc in image_to_string(image, lang, boxes, config) 120 lang=lang, 121 boxes=boxes, --> 122 config=config) 123 if status: 124 errors = get_errors(error_string)

C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.pyc in run_tesseract(input_filename, output_filename_base, lang, boxes, config) 44 command += shlex.split(config) 45 ---> 46 proc = subprocess.Popen(command, stderr=subprocess.PIPE) 47 status = proc.wait() 48 error_string = proc.stderr.read()

C:\ProgramData\Anaconda2\lib\subprocess.pyc in init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags) 388 p2cread, p2cwrite, 389 c2pread, c2pwrite, --> 390 errread, errwrite) 391 except Exception: 392 # Preserve original exception in case os.close raises.

C:\ProgramData\Anaconda2\lib\subprocess.pyc in _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, to_close, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) 638 env, 639 cwd, --> 640 startupinfo) 641 except pywintypes.error, e: 642 # Translate pywintypes.error to WindowsError, which is

WindowsError: [Error 2] The system cannot find the file specified

最佳答案

tesseract-ocr 安装 google tesseract-ocr .代码可能会遗漏依赖项。

关于python - 无法使用pytesseract从图像中获取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45048698/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com