Pytesseract: Tesseract is not installed or it is not in your path in Python

Dung Do Tien May 30 2021 1347

I'm trying to run a basic and very simple code in python. I want to load an image and read text from it as below:

 from PIL import Image
import pytesseract

im ="sample1.jpg")

text = pytesseract.image_to_string(im, lang = 'eng')


But I got an error: TesseractNotFound Error: tesseract is not installed or it's not in your path.

File, line 169, in <module> results.append(pytesseract.image_to_string(im))
File /usr/local/lib/python2.7/dist-packages/pytesseract/, line 286, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)
File /usr/local/lib/python2.7/dist-packages/pytesseract/, line 201, in run_and_get_output
   raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

I'm using tesseract version 3.04.01.

Thanks for any suggestions.

Have 2 answer(s) found.
  • B

    Ba Một Hai May 30 2021

    I see steps are scattered in different answers. Based on my recent experience with this pytesseract error on Windows, writing different steps in sequence to make it easier to resolve the error:

    Step 1. Install tesseract using windows installer available at:

    Step 2. Note the tesseract path from the installation. The default installation path at the time of this edit was: C:\Users\USER\AppData\Local\Tesseract-OCR. It may change so please check the installation path.

    Step 3pip install pytesseract

    Step 4. Set the tesseract path in the script before calling image_to_string:

    pytesseract.pytesseract.tesseract_cmd = r'C:\Users\USER\AppData\Local\Tesseract-OCR\tesseract.exe'

  • T

    Trần quốc cường May 30 2021

    This error is because tesseract is not installed on your computer.

    If you are using Ubuntu install tesseract using the following command:

     sudo apt-get install tesseract-ocr

    For mac:

     brew install tesseract

    I hope it useful for you!!

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close