【发布时间】:2020-05-06 22:29:10
【问题描述】:
我正在使用 Tesseract 进行 OCR。当我在本地工作时,它工作正常,但当我部署到 Google App Engine 时,我无法让它工作。
这是部署中代码中断的行:
d = pytesseract.image_to_data(img, output_type=Output.DICT)
我从 gcloud app logs tail -s
得到这个错误文件“/app/pol_flow.py”,第 1587 行,在 upload_ocr d = pytesseract.image_to_data(img, output_type=Output.DICT) 文件 “/usr/local/lib/python3.6/site-packages/pytesseract/pytesseract.py”, 第 409 行,在 image_to_data 如果 get_tesseract_version() 文件 “/usr/local/lib/python3.6/site-packages/pytesseract/pytesseract.py”, 第 118 行,在包装器中 wrapper._result = func(*args, **kwargs)
文件 “/usr/local/lib/python3.6/site-packages/pytesseract/pytesseract.py”, 第 327 行,在 get_tesseract_version 中引发 TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: /app 没有安装 或者它不在你的路径中TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: /app is not installed> 或者它不在你的路径中
我知道我必须像这样将位置传递到代码中:
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
但我在进行部署时不知道 Tesseract 的安装路径。
感谢您的帮助!
PS:我关注了this answer,但是当我向 App Engine 中部署的端点发出请求时,我仍然收到相同的错误:TesseractNotFoundError()
【问题讨论】:
-
嗨,你能分享一下你正在使用的命令吗? gcloud 应用部署?如果您可以添加标志“--verbosity=debug”并粘贴结果,好吗?
-
嗨@BraulioBaron,我用日志中的错误更新了问题。部署工作正常,问题是当我向端点发出请求时,因为 Tesseract 找不到它的安装位置。
-
@BraulioBaron gcloud app deploy pol-app.yaml --verbosity=debug
-
您好 Ari,Tesseract 库需要 App Engine 标准 Python3 运行时不附带的平台包。作为一种解决方法,您可以检查 this answer 在 Cloud Run 中部署您的应用。
-
@llompalles 我遵循了那个答案,但我在部署时仍然收到错误:'TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: /app is not installed or it's not in your path'
标签: python google-app-engine tesseract gcloud google-app-engine-python