首页 > 解决方案 > /bin/sh: 1: exec: gunicorn: 未找到

问题描述

我正在尝试在谷歌云应用引擎上部署一个简单的 django 应用。应用程序具有基本的 wsgi 和 asgi 服务器,其中 wsgi 服务于 HTTPS 请求,而 asgi 服务于 websocket 请求。我正在按照谷歌应用程序引擎教程来部署应用程序,并且它已成功构建和部署。但是,它无法在已部署的工作空间中找到已安装的软件包。

这些是我正在遵循的步骤

gcloud init
virtualenv myenv
source activate myenv/bin/activate
pip install -r requirements.txt
gcloud app deploy

requirements.txt 确实有 gunicorn 和 daphne,它们也被安装了。

这是我在浏览器上打开已部署的应用程序时遇到的错误。

2020-12-15 20:48:25 my-service[20201216t014451]  /bin/sh: 1: exec: gunicorn: not found

这就是我的 app.yaml 文件的样子

runtime: python38
service: my-service
instance_class: F2

entrypoint: gunicorn -b :$PORT main:app
handlers:
  - url: /.*
    script: auto
    secure: always

inbound_services:
- warmup

automatic_scaling:
  min_instances: 1
  min_idle_instances: 1
  max_instances: 2
  max_idle_instances: 1

我也尝试过在入口点传递确切的路径,即入口点:gunicorn -b :$PORT main:app但得到了同样的错误

我在我的 virtualenv 中调用gcloud app deploy但是当它被部署时,它无法读取已安装的包,即 daphne 和 gunicorn。它们都在具有相同包的同一目录中的本地环境中工作得很好。

我已经提到了这些问题这个这个并尝试了答案,但没有任何效果。

标签: google-app-enginegoogle-cloud-platformgoogle-compute-enginegunicorndaphne

解决方案


GAE 应用引擎需要与 app.yaml 位于同一目录中的 requirements.txt 文件。

我的 requirements.txt 文件位于子文件夹中,这就是谷歌应用引擎无法安装 gunicorn 的原因。我在本地安装要求并在部署时传递已安装的要求,但似乎不需要在本地安装它们(除了在本地服务器上测试更改)。


推荐阅读