如何将要安装的 python 包(使用 apt-get)放置在 GCP 应用引擎的requirements.txt 中

2024-03-27

我正在尝试在 GCP 应用程序引擎中运行我的应用程序。我的Requirements.txt 文件如下所示:

pillow==5.1.0
pybase64==0.4.0
poppler-utils==0.68.0 

Poppler-utils 只能在 GCP 命令行工具中使用 sudo apt-get 来安装。如何在requirements.txt中给出它,以便应用程序使用sudo apt-get命令单独安装该包?


requirements.txt 文件特定于 pip,只能包含 Python 包。

如果您需要安装操作系统级软件包(使用 apt-get),则需要使用基于 Docker 的 App Engine 灵活环境(标准版不提供此功能)并创建一个自定义运行时 https://cloud.google.com/appengine/docs/flexible/custom-runtimes/about-custom-runtimes.

你可以找到一个 Dockerfile 示例here https://github.com/GoogleCloudPlatform/python-runtime#kubernetes-engine--other-docker-hosts扩展默认的 python 图像:

FROM gcr.io/google-appengine/python

然后您需要添加poppler-utils包裹通过:

RUN apt-get install poppler-utils

您将找到有关为 App Engine Flexible 构建自定义运行时的更多信息here https://cloud.google.com/appengine/docs/flexible/custom-runtimes/build.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将要安装的 python 包(使用 apt-get)放置在 GCP 应用引擎的requirements.txt 中 的相关文章

随机推荐