Ismael
Ismael

Reputation: 53

Is there any way to install Tesseract OCR in a venv/web server?

I made a Python script that does OCR, and then I recycled the script and made a web app using Flask. The web app and its libraries are in a virtualenv, but the app is using the Tesseract OCR that was installed in the OS (Windows). I've been testing it from the local server. Now it is time for deployment, and I don't know how to install Tesseract in the venv or if it is possible to install it on a server. I don't know if what I'm saying makes sense, but I'm very lost and I will really appreciate any help with this matter.

Thank you in advance.

Upvotes: 5

Views: 5359

Answers (2)

f4z3k4s
f4z3k4s

Reputation: 1249

If the problem you're facing is ModuleNotFoundError: No module named 'Image' even after installing Pillow, run:

python -m pip install --upgrade pip
python -m pip install --upgrade Pillow

After that, you should be able to install pytesseract without errors.

Upvotes: 1

v25
v25

Reputation: 7641

This would depend on the operating system of the server which you're deploying to. If you're running in docker, this is the OS of the base image.

Most likely you'll install from from a pre-built binary.

Once you've installed, locate the binary. On linux use the command:

which tesseract

this will output something like:

/usr/bin/tesseract

Then in your application code, as per the usage instructions point pytesseract to this binary:

pytesseract.pytesseract.tesseract_cmd = r'/usr/bin/tesseract'

Upvotes: 1

Related Questions