【问题标题】:tabula.errors.JavaNotFoundError error while using tabula in Google cloud functiontabula.errors.JavaNotFoundError 在谷歌云功能中使用 tabula 时出错
【发布时间】:2022-01-19 13:14:53
【问题描述】:

对于我的应用程序,我使用 tabula 包将 pdf 转换为 csv。我写的云函数是在python3.7中的。我把它写在 requirements.txt 文件中。但是我收到了这个错误

File "/layers/google.python.pip/pip/lib/python3.7/site-packages/tabula/io.py", line 91, in _run raise JavaNotFoundError(JAVA_NOT_FOUND_ERROR) tabula.errors.JavaNotFoundError: `java` command is not found from this Python process.Please ensure Java is installed and PATH is set for `java`

需求文件

tabula-py==1.4.1

ma​​in.py

import tabula
df = tabula.read_pdf('/tmp/' + file_id +'.pdf', pages = required_page)[0]
tabula.convert_into('/tmp/' + file_id +'.pdf', '/tmp/' + file_id +'.csv',output_format="csv",pages=required_page, stream=False)

我该如何解决这个问题?有什么替代方法吗?

【问题讨论】:

  • 我也试过1.3.1版本,同样的错误
  • 我试过 Camelot,但这需要 Ghostscript。

标签: python-3.x google-cloud-functions tabula-py


【解决方案1】:

由于 Java 未包含在 Google Cloud Functions Python3.7 使用的 runtime image 中,因此该错误是意料之中的。

这意味着无法在 Python 云函数中使用此库,因为 Java 不在 included system packages 中。

但是,作为替代方案,您可以使用 Google Cloud Run,这是一种更现代的产品,涵盖与 Cloud Functions 相同的功能。您可以使用这个Quickstart 来部署您的第一个服务,然后在您的 Dockerfile 中安装 Java,或者使用安装了 Java 的另一个 Docker 映像。

【讨论】:

    猜你喜欢
    • 2019-06-07
    • 2022-12-17
    • 1970-01-01
    • 2017-11-14
    • 2019-01-19
    • 2022-12-17
    • 1970-01-01
    • 2023-01-25
    • 2017-11-10
    相关资源
    最近更新 更多