【问题标题】:Can't deploy Tesseract to Google App Engine无法将 Tesseract 部署到 Google App Engine
【发布时间】: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


【解决方案1】:

您的问题的正确答案是使用 App Engine Standard 无法做到这一点。您可以使用 App Engine 柔性环境实现此目的:您可以选择 Custom RuntimeDockerfile,这样您就可以安装所需的一切,在这种情况下,只需添加 apt-get install tesseract-ocr 即可安装 Tesseract。

另一个选项是使用Cloud Run,正如@llompalles 所建议的那样。我已经实现了the solution he shared,它对我有用。

【讨论】:

    猜你喜欢
    • 2018-11-22
    • 1970-01-01
    • 2020-12-22
    • 2011-07-28
    • 1970-01-01
    • 2015-02-19
    • 2012-02-11
    • 1970-01-01
    • 2017-09-29
    相关资源
    最近更新 更多