Skip to content Skip to sidebar Skip to footer

Tesseractnotfounderror: Tesseract Is Not Installed Or It's Not In Your Path

I am trying to use tesseract-OCR to print text from the image. But I am getting the above error. I have installed tesseract OCR using https://github.com/UB-Mannheim/tesseract/wiki

Solution 1:

Step 1: Download and install Tesseract OCR from this link.

Step 2: After installing find the "Tesseract-OCR" folder, double Click on this folder and find the tesseract.exe.

Step 3: After finding the tesseract.exe, copy the file location.

Step 4: Pass this location into your code like this

pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"

Note: C:\Program Files\Tesseract-OCR\tesseract.exe == your copied location

Solution 2:

You should to install :

! apt install tesseract-ocr! apt install libtesseract-dev

And

! pip install Pillow
! pip install pytesseract

import pytesseract
fromPILimportImageEnhance, ImageFilter, Image

I have code on Cola from google drive to run. Below of my example code:

I took any example picture of text on website

Step 1: import some packages

import pytesseract
import cv2
import matplotlib.pyplotas plt
fromPILimportImage

Step 2 : Upload file of text.png on Colab

from google.colab import files
uploaded = files.upload()

current browser session. Please rerun this cell to enable.
---------------------------------------------------------------------------
MessageError                              Traceback (most recent calllast)
<ipython-input-31-21dc3c638f66>in<module>()
      1from google.colab import files
----> 2 uploaded = files.upload()2 frames
/usr/local/lib/python3.6/dist-packages/google/colab/_message.py in read_reply_from_input(message_id, timeout_sec)
    104         reply.get('colab_msg_id') == message_id):
    105       if 'error'in reply:
--> 106         raise MessageError(reply['error'])107return reply.get('data', None)
    108 
MessageError: TypeError: Cannot read property '_uploadFiles'of undefined

-> Don't worry, please run code again it will accept it. And then, you could choose which if you want to upload

Step 3 :

  • read the image using OpenCV

    image = cv2.imread("text.png")

  • or you can use Pillow

    image = Image.open("text.png")

  • check it. Have they show file text picture.

    image

get the string

string = pytesseract.image_to_string(image)

print it

print(string)

Done.

Post a Comment for "Tesseractnotfounderror: Tesseract Is Not Installed Or It's Not In Your Path"