I am working on an OCR using Tesseract. When I work local it works fine, but I can't make it work when I deploy to Google App Engine.
This is the line where the code breaks in the deploy:
d = pytesseract.image_to_data(img, output_type=Output.DICT)
I get this error from the gcloud app logs tail -s
File "/app/pol_flow.py", line 1587, in upload_ocr d = pytesseract.image_to_data(img, output_type=Output.DICT) File "/usr/local/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 409, in image_to_data if get_tesseract_version() < '3.05':
File "/usr/local/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 118, in wrapper wrapper._result = func(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 327, in get_tesseract_version raise TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: /app is not installed or it's not in your pathTesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: /app is not installed> or it's not in your path
I know that I have to pass the location into the code like this:
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
But I don't know the path where Tesseract is installed when I make the deploy.
Thanks for your help!
PS: I followed this answer but when I make the request to the deployed endpoint in App Engine I still get the same error: TesseractNotFoundError()
the proper answer to your question would be that is not possible to do this with App Engine Standard. You can achieve this with App Engine Flexible environment: you can opt for a Custom Runtime with a Dockerfile that allows you to install everything you need, in this case, Tesseract simply by adding apt-get install tesseract-ocr
.
The other option would be to use Cloud Run , just as suggested by @llompalles. I have implemented the solution he shared and it works for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.