云构建pytest找不到Ghostscript库

时间:2020-10-19 09:29:42

标签: google-cloud-platform yaml ghostscript google-cloud-build

我正在尝试创建一个触发器,以在将功能部署到cloud function之前对其进行测试。到目前为止,我设法安装了requirements.txt并执行了pytest,但是出现了以下错误:

/usr/local/lib/python3.7/site-packages/ghostscript/__init__.py:35: in <module>
    from . import _gsprint as gs
/usr/local/lib/python3.7/site-packages/ghostscript/_gsprint.py:515: in <module>
    raise RuntimeError('Can not find Ghostscript library (libgs)')
E   RuntimeError: Can not find Ghostscript library (libgs)

我的ghostscript文件中有requirements.txt

[...]
ghostscript==0.6
[...]
pytest==6.0.1
pytest-mock==3.3.1

这是我的deploy.yaml

steps:
  - name: 'docker.io/library/python:3.7'
    id: Test
    entrypoint: /bin/sh
    dir: 'My_Project/'
    args:
    - -c
    - 'pip install -r requirements.txt && pytest pytest/test_mainpytest.py -v'

从回溯中,我了解到我没有在云构建上安装ghostscript,这是真的。

有没有办法在我的ghostscript的台阶上安装deploy.yaml

编辑1:

所以我试图一步一步地使用命令来安装ghostscript,我尝试了apt-get gsapt-get ghostscript,但不幸的是它没有用

1 个答案:

答案 0 :(得分:3)

真正的问题是您缺少c库,软件包本身似乎是由pip安装的。您应该使用包管理器安装该库。这是基于ubuntu的容器的示例:

  - name: 'gcr.io/cloud-builders/gcloud'
    entrypoint: 'bash'
    args:
      - '-c'
      - |
        apt update
        apt install ghostscript -y
        pip install -r requirements.txt
        pytest pytest/test_mainpytest.py -v