【问题标题】:File 'tesseract.log' is Missing (Python 2.7, Windows)文件“tesseract.log”丢失(Python 2.7,Windows)
【发布时间】:2017-01-28 02:42:53
【问题描述】:

我正在尝试使用 Python(2.7,Windows 操作系统)编写 OCR 脚本以从图像中获取文本。首先,我下载了 PyTesser 并将其作为 'pytesser' 解压缩到 Python27/Lib/site-packages 中,并使用 pip install tesseract 安装了 tesseract。然后我将以下脚本编写为 self.py:

from PIL import Image
from pytesser.pytesser import *

image_file = 'C:/Users/blabla/test.png'
im = Image.open(image_file)
text = image_to_string(im)
text = image_file_to_string(image_file)
text = image_file_to_string(image_file, graceful_errors=True)
print text

但我收到以下错误:

Traceback (most recent call last):
  File "C:/Users/blabla/self.py", line 7, in <module>
    text = image_file_to_string(image_file)
  File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 44, in image_file_to_string
    call_tesseract(filename, scratch_text_name_root)
  File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 24, in call_tesseract
    errors.check_for_errors()
  File "C:\Python27\lib\site-packages\pytesser\errors.py", line 10, in check_for_errors
    inf = file(logfile)
IOError: [Errno 2] No such file or directory: 'tesseract.log'

是的,任何地方都没有“tesseract.log”文件。我该怎么办?我该如何解决这个问题?

提前谢谢你。

注意:我已将行 tesseract_exe_namepytesser.pytesseract 更改为 C:/Python27/Lib/site-packages/pytesser /tesseract 但它不起作用。

编辑:好的,我刚刚运行了 'pytesser' 中的 teseract.exe,它创建了 'tesseract.log' 文件,但我还在得到同样的错误。

【问题讨论】:

    标签: python ocr tesseract


    【解决方案1】:

    我已将 ../pytesser/errors.py 中的行从 def check_for_errors(logfile = "tesseract.log"): 更改为 def check_for_errors(logfile = "C:/Python27/Lib/site-packages/pytesser/tesseract.log"): 并且有效。

    【讨论】:

      猜你喜欢
      • 2017-09-05
      • 2018-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多