Forum Discussion

tamasv's avatar
tamasv
New Member
1 year ago
Solved

Tesseract install

I want to use pytesseract in a notebook. I have added pytesseract to my environment. I can import it. However it does not work, I get an error when trying to run: pytesseract.image_to_string() E...
  • cmaneu's avatar
    1 year ago

    Hello tamasv,
    nilendraFabric is right. PyTesseract relies on Tesseract binary and libraries. They're not part of the Fabric environment, and there is no easy way to download them. Depending on your use case, you may have several options.

    Use EasyOCR

    nilendraFabric suggestion was good. This library works within Fabric. Here is a sample code.

    %pip install easyocr
    import easyocr
    reader = easyocr.Reader(['en'])
    result = reader.readtext("/lakehouse/default/Files/screenshot.png")
    for detection in result:
        print(detection[1])

    In my (small) experience, tesseract provides better results than easyOCR, so please check your use cases.


    Use Azure Services

    Azure Vision AI Services provides several ML models to extract both printed and handwritter text. With Document intelligence, you can even extract structured information - for example parsing an image of an invoice and automatically get each line item.



    Tesseract - manually build and reference
    If you really want to use Tesseract, Technically, you could hand-install tesseract packages, this will involve manually downloading (deb) packages and untar them, but that would be quite time-consuming with all the chain of dependency. You could also compile it yourself to have a single exe with all the dependencies linked (someone on the Internet may have done that alreay).

    Hope this helps!