How do I resolve a TesseractNotFoundError?

前端 未结 22 1896
情话喂你
情话喂你 2020-11-28 05:14

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

    raise TesseractNotFoundError()
pytesseract.pytesseract.TesseractNo         


        
相关标签:
22条回答
  • 2020-11-28 05:56

    For Mac:

    1. Install Pytesseract (pip install pytesseract should work)
    2. Install Tesseract but only with homebrew, pip installation somehow doesn't work. (brew install tesseract)
    3. Get the path of brew installation of Tesseract on your device (brew list tesseract)
    4. Add the path into your code, not in sys path. The path is to be added along with code, using pytesseract.pytesseract.tesseract_cmd = '<path received in step 3>' - (e.g. pytesseract.pytesseract.tesseract_cmd = '/usr/local/Cellar/tesseract/4.0.0_1/bin/tesseract')

    This should work fine.

    0 讨论(0)
  • 2020-11-28 05:56

    Just run these command if you are using linux,

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

    then run this,

    python -m pip install tesseract tesseract-ocr pytesseract
    
    0 讨论(0)
  • 2020-11-28 05:58

    I faced the same problem. I hope you have installed from here and have also done pip install pytesseract.

    If everything is fine you should see that the path C:\Program Files (x86)\Tesseract-OCR where tesseract.exe is available.

    Adding Path variable did not helped me, I actually added new variable with name tesseract in environment variables with a value of C:\Program Files (x86)\Tesseract-OCR\tesseract.exe.

    Typing tesseract in the command line should now work as expected by giving you usage informations. You can now use pytesseract as such (don't forget to restart your python kernel before running this!):

    import pytesseract
    from PIL import Image
    
    value=Image.open("text_image.png")
    text = pytesseract.image_to_string(value, config='')    
    print("text present in images:",text)
    

    enjoy!

    0 讨论(0)
  • 2020-11-28 05:58

    There Are few steps to set the path

    1:goto this "https://github.com/UB-Mannheim/tesseract/wiki"

    2:download the latest installers

    3:install it

    4: set the path in system variables such as "C:\Program Files\Tesseract-OCR" or "C:\ProgramFiles (x86)\Tesseract-OCR"

    5 : open CMD type "tesseract" and some output except "not regonized type errors"

    0 讨论(0)
提交回复
热议问题