在将我的应用程序部署到 Google App Engine (Python 2.7) 时,我遇到了一个奇怪的依赖关系问题。
我在 requirements.txt 文件中指定了我的依赖项:
Flask==1.0.2
werkzeug>=0.14
flask-cors
twilio
httplib2
gunicorn
Jinja2
google-cloud-ndb
exponent_server_sdk
当使用 requirements.txt 文件夹中的 pip 在本地安装时,这些可以在本地开发服务器上正常工作。
但是,当我部署到应用引擎时,似乎尚未安装模块 exponent_server_sdk(ImportError:没有名为 exponent_server_sdk 的模块)。
我通常通过推送到 git 存储库进行部署,然后使用 Google Cloud Build(“gcr.io/cloud-builders/gcloud”)进行部署。部署时没有错误,requirements.txt 文件中的其他依赖项工作正常,例如 twilio 或 Jinja2。
在对此进行调查时,我尝试使用 gcloud app deploy 直接从我的开发机器推送。当我这样做时,出于某种奇怪的原因,exponent_server_sdk 可用并且可以正常工作。
这种行为对我来说似乎很奇怪,我找不到任何遇到类似错误的人的文档。我想知道是否有人可以就可能导致此问题的原因或我可以查找错误的地方给我任何指导(例如,在部署/实例启动期间安装 requirements.txt 文件的过程的日志)。
回应评论:
我在标准环境中运行。
我的 cloudbuild.yaml 看起来像这样:
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy", "app.yaml", "dispatch.yaml", "service_1.yaml", "service_2.yaml", "service_3.yaml", "index.yaml"]
timeout: "1600s"
我遇到错误的服务的 .yaml 文件如下所示:
runtime: python27
api_version: 1
threadsafe: true
service: notifications
libraries:
- name: ssl
version: latest
handlers:
- url: /.*
script: notifications.app