Search code examples
pythonimagetesseractstringio

Error 2 No such file or directory in pytesseract


I want try to read the simple image But I have the follwoing error:

import requests
import pytesseract
from PIL import Image
from StringIO import StringIO
from lxml import html
session=requests.Session()
cont=session.get('http://This_site.com/').content
tree=html.fromstring(cont)
token=tree.xpath(...)
session_id=token.split(...)
response=session.get('http://This_site.com/'+session_id)
captcha=pytesseract.image_to_string(Image.open(StringIO(response.content)))
print captcha

The Error:

[Errno 2] No such file or directory

Solution

  • Seems like you don't have tesseract-ocr installed, try this one if you're using debian-based distro:

    $ sudo apt-get install tesseract-ocr