You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google App Engine中Firestore应用启动报错:No module named 'google.cloud.location'

问题排查与解决方案

问题根源

ModuleNotFoundError: No module named 'google.cloud.location' 是因为依赖环境缺少包含google.cloud.location proto定义的包,具体原因:

  • googleapis-common-protos==1.54.0版本过低,google.cloud.location模块是在该包的1.56.0及以上版本中才新增的
  • 由firebase_admin间接引入的google-cloud-firestore新版本,需要依赖上述新增模块,但当前环境未满足该依赖要求

修复步骤

  1. 更新项目的requirements.txt,调整后的内容如下:
    firebase_admin==3.0.0
    sendgrid==6.9.3
    google-auth==1.35.0
    google-auth-httplib2==0.1.0
    jinja2==3.0.3
    MarkupSafe==2.0.1
    pytz==2021.3
    Flask==2.0.2
    twilio==6.46.0
    httplib2==0.20.2
    requests==2.24.0
    requests_toolbelt==0.9.1
    google-cloud-tasks==2.7.1
    google-cloud-logging==1.15.1
    googleapis-common-protos==1.59.0  # 升级到包含location proto的版本
    protobuf==3.20.1
    google-cloud-firestore==2.7.2  # 明确指定兼容版本,避免间接依赖冲突
    
  2. 清理本地依赖缓存(若有本地测试环境):
    pip uninstall -y -r requirements.txt
    pip install -r requirements.txt --no-cache-dir
    
  3. 重新部署到App Engine:
    gcloud app deploy
    

额外说明

  • 明确指定google-cloud-firestore版本,可避免firebase_admin引入的版本与其他Google Cloud服务依赖产生冲突
  • Google Cloud相关依赖版本差异过大时,极易引发此类模块缺失或兼容性问题,建议保持核心依赖版本的匹配性

内容的提问来源于stack exchange,提问作者Jack tileman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 15:50:36