如何在aws-Lambda中安装Ghostscript



错误消息:Please make sure that Ghostscript is installed", "errorType": "RuntimeError"

import camelot
def pdfToJson(event=None, context=None): 
tables = camelot.read_pdf("./week-1-2019-20.pdf")  
tables[0].df.to_json("./sample.json")
  1. 使用pip-install-t安装依赖项
  2. 但仍然会出错

如何在python代码中安装"ghostscript"依赖项?

我自己还没有尝试过,但您应该可以使用Lambda Layer来做到这一点。您可以通过https://github.com/BearTail/ghostscript-aws-lambda-layer.

可能还需要一些魔法来告诉camelot Ghostscript二进制文件可以在/opt/bin/gs找到,因为这不是它的正常位置

camelot库中,通过使用ctypes的低级C-API接口与Ghostscript进行通信。Ghostscript用于从库正在处理的pdf中生成图像。

您不需要自己安装任何python绑定,唯一的要求就是Ghostscript本身。最简单的安装方法是使用存储库/CD,在Ubuntu上简单如下:

sudo apt-get install -y ghostscript
gs --version

最新更新