【问题标题】:Tesseract OCR Python Error正方体 OCR Python 错误
【发布时间】:2017-10-04 19:13:14
【问题描述】:

我正在尝试安装 tesseract,但如果我按照所有步骤操作,我仍然会收到错误消息。

Traceback (most recent call last):
  File "C:\Users\julian\Documents\Schikka\tesseract.py", line 3, in <module>
    print(pytesseract.image_to_string(Image.open('images/test.jpg')))
  File "C:\Users\julian\AppData\Local\Programs\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
    config=config)
  File "C:\Users\julian\AppData\Local\Programs\Python\Python35\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
    proc = subprocess.Popen(command, stderr=subprocess.PIPE)
  File "C:\Users\julian\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "C:\Users\julian\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2]  the system cannot find the file specified. 

我也尝试在 linux 上安装它,但仍然收到错误代码。

我目前有 python 3.6

这是我尝试过的代码:

from PIL import Image
import pytesseract
print(pytesseract.image_to_string(Image.open('images/test.jpg')))

请帮帮我。

【问题讨论】:

  • 文件的路径可能不正确,因为 traceback 呼吁。请检查图片路径!!!
  • @Julian - 确保您的 tesseract 二进制文件与您的 py 文件位于同一文件夹中,或者位于系统路径之一中。
  • @Julian 对下面我的回答有任何反馈吗?

标签: python python-3.x ocr tesseract


【解决方案1】:

您似乎没有安装tesseract 和/或错误地配置了路径。您可以尝试以下步骤。

  1. 为 64 位 Windows 下载并安装 tesseract 4.0 alpha here
  2. C:\Program Files\Tesseract 4.0.0 添加到 Windows 环境变量PATH
  3. 设置 Windows 环境变量 TESSDATA_PREFIXC:\Program Files\Tesseract 4.0.0\tessdata
  4. 在命令提示符下键入tesseract -v 以验证它是否正常工作。假设tesseract version 信息将返回。

请注意,上面的路径是一个示例。您需要将其设置为您的实际程序安装路径。

那么你可以修改你的pytesseract command如下再试一次。

ocr = pytesseract.image_to_string(image, lang='eng', boxes=False, \
        config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')

希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-10
    • 2015-04-21
    • 2013-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多