Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve a TesseractNotFoundError?

I am trying to use pytesseract in Python but I always end up with the following error:

    raise TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path 

However, pytesseract and Tesseract are installed on my system.

Example code that produces this error:

import cv2 import pytesseract  img = cv2.imread('1d.png') print(pytesseract.image_to_string(img)) 

How do I resolve this TesseractNotFoundError?

like image 513
PreetyP Avatar asked Jun 02 '18 10:06

PreetyP


People also ask

How do I edit path environment variable and add Tesseract path?

We want to use Tesseract from our windows command line and to do that, we have to add Tesseract to our path in the system's environment variable. To do so, click on your start button on windows and search “environment variable”. You will see a result called “Edit the system environment variables”. Click on that.

How do I know if Tesseract is installed?

To verify if Tesseract is successfully installed, you can hit your terminal and type the following. If you receive a few lines of prompt similar to the one below, your Tesseract is installed correctly. Otherwise, you might want to check what has gone wrong by starting from your PATH variable in your system.

Do I need to install Tesseract to use Pytesseract?

You can confirm that pytesseract is installed in your virtual environment by hopping into the Python REPL and trying to import it. pytesseract is installed. Great! But before we can use it, we need to install the tesseract application.


1 Answers

I got this error because I installed pytesseract with pip but forget to install the binary.

On Linux

sudo apt update sudo apt install tesseract-ocr sudo apt install libtesseract-dev 

On Mac

brew install tesseract 

On Windows

download binary from https://github.com/UB-Mannheim/tesseract/wiki. then add pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe' to your script. (replace path of tesseract binary if necessary)

references: https://pypi.org/project/pytesseract/ (INSTALLATION section) and https://github.com/tesseract-ocr/tesseract/wiki#installation

like image 105
Ali Avatar answered Oct 11 '22 01:10

Ali