How to use tesseract in heroku?

484 Views Asked by At

I wanna know how to use pytesseract in Heroku, I installed using pip install but when, I put path it gives error. I tried using Build packs too but I can't get path. please help me.

1

There are 1 best solutions below

1
On BEST ANSWER

Option 1: with build packs

The build pack executables are in the $INSTALL_DIR directory.

Take a look at this question Heroku buildpacks - installing executables that are used by Python packages to customize your path in a build pack (just clone the build pack git and change your PATH).

Option 2: With custom docker image

Another option is to build your own docker image with based in the official python docker image (ie python:3.8-buster) and install tesseract.

You can use this dockerfile:

FROM python:3.8-buster

RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository -y ppa:alex-p/tesseract-ocr
RUN apt-get update && apt-get install -y tesseract-ocr-all 

RUN mkdir /home/work
WORKDIR /home/work

Once you have this docker image, you can push it to heroku private docker registry and use it to run your dynos.