2017-04-19 9 views
2

나는 다음과 같은 코드 오류가 점점 계속으로 이미지를 변환 할 때 :pytesseract 오류 문자열

import pytesseract 
from PIL import Image, ImageEnhance, ImageFilter 

im = Image.open("book.jpg") # the second one 
im = im.filter(ImageFilter.MedianFilter()) 
enhancer = ImageEnhance.Contrast(im) 
im = enhancer.enhance(2) 
im = im.convert('1') 
text = pytesseract.image_to_string(im) 
print text 

오류는 다음과 같습니다이 설치 문제의 경우

File "demo2.py", line 9, in <module> 
text = pytesseract.image_to_string(im) 
File "/home/vagrant/src/env/local/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 161, in image_to_string 
config=config) 
File "/home/vagrant/src/env/local/lib/python2.7/site-packages/pytesseract/pytesseract.py", line 94, in run_tesseract 
stderr=subprocess.PIPE) 
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__ 
errread, errwrite) 
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child 
raise child_exception 
OSError: [Errno 2] No such file or directory 

잘 모르겠어요 또는 다른 것. OSError: [Errno 2] No such file or directory using pytesser에 대한 답변을 읽었지만 도움이되지 않았습니다.

+0

는 지금 작동합니까? – Veltro

답변

0

나는 동일한 문제가 있었지만 이미지를 문자열로 변환 할 수있었습니다. 트릭해야 apt-get를 사용하여 :

sudo apt-get install tesseract-ocr 

을하고 파이썬 스크립트에서 사용할 수없는 경우 바로 다음을 수행

from os import system 

system("tesseract -l eng /image.png text.txt")