2

I am trying to read the text in a cheque using pytesseract OCR. I have installed the required python packages required for this task e.g. pip install pytesseract.

However when I try to use the package to read the file I get the following error:

 pytesseract.image_to_string(im, lang='eng')
Traceback (most recent call last):

  File "<ipython-input-17-d7d9f430493b>", line 1, in <module>
    pytesseract.image_to_string(im, lang='eng')

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 294, in image_to_string
    return run_and_get_output(*args)

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 202, in run_and_get_output
    run_tesseract(**kwargs)

  File "C:\Users\BRIGHT\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 172, in run_tesseract
    raise TesseractNotFoundError()

TesseractNotFoundError: tesseract is not installed or it's not in your path

This error dosent make sense because I actually import the package without getting any error. But when I try to use it I get the error.

Here is my code:

from PIL import Image
import pytesseract

im=Image.open('BritishChequeAnnotated.jpg')
text=pytesseract.image_to_string(im, lang='eng')
3
  • are you sure you are running your python file with same version you are editing with? I've seen lots of people develop in anaconda and then run in their other python Commented Oct 22, 2018 at 12:54
  • Yes I am doing so. Commented Oct 22, 2018 at 12:56
  • The thing that you're "successfully importing" in Python is just a wrapper. A bridge which connects Python to Tesseract that you should have installed on your machine too. You have to install the actual Tesseract on your pc: github.com/tesseract-ocr/tesseract/wiki/… Commented Oct 22, 2018 at 12:59

2 Answers 2

2

The documentation for tesseract makes this clear.

https://pypi.org/project/pytesseract/

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
Sign up to request clarification or add additional context in comments.

Comments

0

You need to install teserract executable file and include the path into the program then it won't gives any error

1 Comment

Welcome to Stack Overflow. Could you clarify, perhaps with some example code? It's also a good idea to take the tour, and read How to Ask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.