Categories
TUTORIALS

pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it’s not in your path

In this article, we see how to fix the error : “pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it’s not in your path“.

So are you trying to use the Tesseract tool to do OCR using Python? But some how end up with this error? If yes, then this article will help you in fixing this error.

But before I explain you on how to fix it, here is what we will do. Let me explain you about what is happening here in the first place. Alright? Because if you know what is happening, you will be able to fix similar errors in future as well.

It is not just sufficient to know how to fix a problem. But to know why it happened in the first place. Right? So we will do just that.

What Does The Error Mean?

So let us take a look at the error once again, shall we? Here is what the error looks like:

pytesseract.pytesseract.tesseractnotfounderror How To Fix It?
pytesseract.pytesseract.tesseractnotfounderror How To Fix It?
pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it's not in your path

Does that error message makes any sense to you? No? Actually it does. But only if you know more about how Python’s PyTesseract library.

You see, PyTesseract library is a Python wrapper that makes use of the Tessseract application installed on your computer. So for the PyTesseract library to work, it needs to hook in to the Tesseract app first. But to do that, it needs to know where to find it. Right?

So how does the PyTesseract library know where to find it? Well that is where the OS PATH variables come into picture.

The Python library looks for an OS PATH variable called tesseract. So it is in this variable does it expect to find the path to the Tesseract app.

But when the library cannot find this PATH variable, or the Tesseract app, it will throw the error:

pytesseract.pytesseract.tesseractnotfounderror: tesseract is not installed or it's not in your path

So now that you know the root cause, what is the solution?

How To Fix pytesseract.pytesseract.tesseractnotfounderror?

To fix this problem, you have to follow these few simple steps:

  1. Make sure that Tesseract application is installed.
  2. Make sure that the OS PATH variable tesseract is set to point to the above application file.
    • So if you are on Windows, the tesseract PATH variable will have a value something like this: C:\Program Files (x86)\Tesseract-OCR\tesseract.exe. To find this out, type the below command:
      • echo $tesseract
    • But if you are on Mac or Linux (eg: Ubuntu), it will look like this: /usr/local/bin/tesseract. To find this out, type the below command:
      • echo $tesseract

So that is it! That is how you fix the tesseractnotfounderror error on your Python program.

Hope this helps. Do let me know if you have any questions and I will be happy to answer. See you in the next article. Cheers!

Do You Know The Difference Between Expression Vs Statement In Python?