2016-09-20 41 views
0

我试图用Python(2.7,Windows OS)编写OCR脚本来从图像中获取文本。首先,我下载了PyTesser,并将其作为“pytesser”提取到Python27/Lib/site-packages,并且我已安装了带有pip install tesseract的tesseract。然后,我写了下面的脚本self.py:文件'tesseract.log'缺少(Python 2.7,Windows)

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”文件的任何地方。我该怎么办?我应该如何解决这个问题?

预先感谢您。

注:我从pytesser.py改了行tesseract_exe_name正方体C:/ Python27 /库/站点包/ pytesser /正方体,但它不工作。

编辑:好吧,我只是拼命地跑teseract.exe这是在“pytesser”,它创造了“tesseract.log”文件,但我仍然得到同样的错误。

回答

0

我已将行从def check_for_errors(logfile = "tesseract.log"):更改为def check_for_errors(logfile = "C:/Python27/Lib/site-packages/pytesser/tesseract.log"):,../pytesser/errors.py并且工作正常。