I am trying to use pytesseract in Python but I always end up with the following error:
raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNo
Install tesseract from https://github.com/UB-Mannheim/tesseract/wiki and add the path of tesseract.exe to the Path environment variable.
Are you importing
from tesseract import image_to_string
Don't import from pytesseract
I was also facing the same issue, just add C:\Program Files (x86)\Tesseract-OCR
to your path variable.
If it still does not work, add C:\Program Files (x86)\Tesseract-OCR\tessdata
to your path variable in a new line. And do not forget to restart your computer after adding the path variable.
I was also facing the same error when I was trying to make a text-extractor using pytesseract, but the solution was there in installation instructions for pytesseract in pypi site: pytesseract There are many alternatives to avoid the error, But, adding one more parameter in the method pytesseract.image_to_string solved it for me, like
tessdata_dir_config = "/usr/share/tesseract-ocr/4.00/tessdata"
output = pytesseract.image_to_string(image, lang='eng', config=tessdata_dir_config)
CAUTION: ONLY FOR WINDOWS
I came across this problem today and all the answers mentioned here helped me, but I personally had to dig a lot to solve it. So let me help all others by putting out the solution to it in a very simple form:
Download the executable 64 bit (32-bit if your computer is of 32 bit) exe from here.
(Name of the file would be tesseract-ocr-w64-setup-v5.0.0.20190526 (alpha))
Install it. Let it install itself in the default C directory.
Now go to your Environment variable (Reach there by just searching it in the start menu or Go to Control Panel > System > Advanced System Settings > Environment Variables
)
a) Select PATH and then Edit it. Click on NEW and add the path where it is installed (Usually C:\Program Files\Tesseract-OCR\
)
Now you will not get the error!
Small mistake -- I knew I had to open/close my cmd to get the updated path to reflect. Using Jupyter Notebook I had to shutdown the client and re-initialize it also.