【问题标题】:Problem occurred when using PyTesseract to recognize text from an image使用 PyTesseract 从图像中识别文本时出现问题
【发布时间】:2018-10-29 07:26:34
【问题描述】:

我正在尝试为我们学校的网站制作一个自动登录程序,该程序需要识别验证码中的文本。于是我从 pip 安装了pytesseract,并在 PyCharm 中运行程序:(图像在目录 /Users/macintosh/Documents/PythonOutputs/2.jpg


import pytesseract

from PIL import Image

image = Image.open("/Users/macintosh/Documents/PythonOutputs/2.jpg")

text = pytesseract.image_to_string(image)

print(text)

但是发生了这个错误:

Traceback(最近一次调用最后一次):文件 "/Users/macintosh/Library/Preferences/PyCharmCE2018.2/scratches/scratch_3.py", 第 5 行,在 text = pytesseract.image_to_string(image)

文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py", 第 294 行,在 image_to_string 中 return run_and_get_output(*args)

文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py", 第 202 行,在 run_and_get_output 中 run_tesseract(**kwargs)

文件 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytesseract/pytesseract.py", 第 178 行,在 run_tesseract raise TesseractError(status_code, get_errors(error_string))

pytesseract.pytesseract.TesseractError: (2, '用法:python pytesseract.py [-l lang] input_file')

有什么问题?

【问题讨论】:

    标签: python python-tesseract


    【解决方案1】:

    好吧,虽然你的错误信息不是很清楚,但我敢打赌(从你的行为来看)你还没有安装 Tesseract 本身。

    在 pytessaract 文档中指出:

    Python-tesseract 是 Google 的 Tesseract-OCR 引擎的包装器。

    所以你应该安装实际的程序(即 Tesseract)来完成这项工作。

    【讨论】:

      猜你喜欢
      • 2016-10-11
      • 2019-12-04
      • 1970-01-01
      • 2021-11-14
      • 1970-01-01
      • 2017-09-10
      • 2021-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多