尝试使用Gcloud应用程序通过Gitlab CI/CD部署的GCLOUD应用程序部署烧瓶应用程序。日志显示ModulenotFoundError:无模块名为'烧瓶'

发布于 2025-02-04 19:48:58 字数 1325 浏览 5 评论 0原文

我有一个可以部署到本地主机的烧瓶应用程序。不幸的是,在尝试将其部署到Google App Engine时,我会遇到错误。当我在gcloud -project $ project_id app exploy app.yaml中遵循控制台中指定的链接时500服务器错误。要调试此问题,我使用了gcloud应用程序日志读取,该显示了一个长期错误,以:

    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed    File 
    "/srv/main.py", line 1, in <module>      from flask import Flask, request, jsonify, 
    abort  ModuleNotFoundError: No module named 'flask'

我的app.yaml文件读取:

entrypoint: "gunicorn -b:$PORT main:app"
service_account: app-engine-admin@###########.iam.gserviceaccount.com
runtime_config:
  python_version: 3

handlers:
- url: .*
  script: main.app

我的sumpllion.txt读取:

firebase_admin==5.2.0
Flask==2.1.2

以及我的.gitlab-ci.yml读取:

gcloud-deploy:
  image: google/cloud-sdk:alpine
  stage: deploy
  only:
    - dev2
  script:
    - echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
    - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
    - gcloud --project $PROJECT_ID app deploy app.yaml
    - rm /tmp/$CI_PIPELINE_ID.json

此错误使我感到困惑,因为我认为我认为所有库中列出的所有库都会使我感到困惑。在部署期间由GAE进口。如果有人遇到了这个问题,或者可以将我指向正确的方向,将不胜感激!

I have a Flask app which is able to be deployed to my localhost. Unfortunately, when attempting to deploy it to Google App Engine I run into an error. When I follow the link specified in the console after the gcloud --project $PROJECT_ID app deploy app.yaml call in my .gitlab-ci.yml file, I recieve a 500 server error. To debug this I used the gcloud app logs read which show a long error ending with:

    File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed    File 
    "/srv/main.py", line 1, in <module>      from flask import Flask, request, jsonify, 
    abort  ModuleNotFoundError: No module named 'flask'

My app.yaml file reads:

entrypoint: "gunicorn -b:$PORT main:app"
service_account: app-engine-admin@###########.iam.gserviceaccount.com
runtime_config:
  python_version: 3

handlers:
- url: .*
  script: main.app

my requirements.txt reads:

firebase_admin==5.2.0
Flask==2.1.2

and the called section of my .gitlab-ci.yml reads:

gcloud-deploy:
  image: google/cloud-sdk:alpine
  stage: deploy
  only:
    - dev2
  script:
    - echo $SERVICE_ACCOUNT > /tmp/$CI_PIPELINE_ID.json
    - gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
    - gcloud --project $PROJECT_ID app deploy app.yaml
    - rm /tmp/$CI_PIPELINE_ID.json

This error is confusing me as I thought that all libraries listed in the requirements.txt file would be imported by GAE during deployment. If someone has run into this or could point me in the right direction it would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫嚣ゝ 2025-02-11 19:48:58

这个答案最终变得很简单。我只是缺少unignts.txt文件中的一些软件包。主要的是Gunicorn软件包。由于未安装,因此Web服务器实际上从未被踩下。这导致了我遇到的问题。我通过使用pipenv lock -r&gt;需求.txt

The answer to this ended up being pretty simple. I was just missing a few packages in the requirements.txt file. The main one being the gunicorn package. Because it was not installed, the web server was never actually spooled up. This led to the issues I ran into. I solved this by using pipenv lock -r > requirements.txt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文