Pytesseract : "TesseractNotFound Error: tesseract is not installed or it's not in your path", how do I fix this?

Jed Bartlet picture Jed Bartlet · Jun 20, 2018 · Viewed 145.6k times · Source

I'm trying to run a basic and very simple code in python.

from PIL import Image
import pytesseract

im = Image.open("sample1.jpg")

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

print(text)

This is what it looks like, I have actually installed tesseract for windows through the installer. I'm very new to Python, and I'm unsure how to proceed?

Any guidance here would be very helpful. I've tried restarting my Spyder application but to no avail.

Answer

Nafeez Quraishi picture Nafeez Quraishi · Dec 7, 2018

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:

1. Install tesseract using windows installer available at: https://github.com/UB-Mannheim/tesseract/wiki

2. Note the tesseract path from the installation. 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.

3. pip install pytesseract

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'