Pytesseract: Tesseract is not installed or it is not in your path in Python
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 = Image.open("sample1.jpg") text = pytesseract.image_to_string(im, lang = 'eng') print(text)
But I got an error: TesseractNotFound Error: tesseract is not installed or it's not in your path.
Traceback: File file.py, line 169, in <module> results.append(pytesseract.image_to_string(im)) File /usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py, 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/pytesseract.py, 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.
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: https://github.com/UB-Mannheim/tesseract/wiki
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.
pip install pytesseract
Step 4. Set the tesseract path in the script before calling
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\USER\AppData\Local\Tesseract-OCR\tesseract.exe'
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
brew install tesseract
I hope it useful for you!!