尝试使用Gcloud应用程序通过Gitlab CI/CD部署的GCLOUD应用程序部署烧瓶应用程序。日志显示ModulenotFoundError:无模块名为'烧瓶'
我有一个可以部署到本地主机的烧瓶应用程序。不幸的是,在尝试将其部署到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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案最终变得很简单。我只是缺少
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 thegunicorn
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 usingpipenv lock -r > requirements.txt
.