Processing math: 100%

Saturday, November 16, 2019

installation of pytesseract

By pip install tesseract we can install a wrapper of an application based on C++ library. It would not install the tesseract application into our computer. If we run import pytesseract and related API, we will get the following error:
1
TesseractNotFoundError: tesseract is not installed or it's not in your path

To get around this problem, install tesseract manually from

and before calling any API of pytesseract we call
1
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
and we are done! For example, consider the following picture called "plain_text.png" in the directory of our .py file:
we run
1
2
3
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
 
text = pytesseract.image_to_string(image)
and we get

No comments:

Post a Comment