云生成pytest找不到Ghostscript库



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)

我的requirements.txt文件中有ghostscript

[...]
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,这是真的。

有没有办法在我的deploy.yaml的一个步骤上安装ghostscript

第1版:

所以我尝试在一个步骤中使用命令安装ghostscript,我尝试了apt-get gsapt-get ghostscript,但不幸的是,它不起作用

真正的问题是缺少一个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

最新更新