【问题标题】:Google Cloud Function Build failed. Error ID: 99f2b037谷歌云函数构建失败。错误 ID:99f2b037
【发布时间】:2022-01-06 03:51:04
【问题描述】:

当我尝试更新代码并重新部署 Google Cloud Function 时,构建失败。

部署脚本:

gcloud functions deploy <my-func-name> --entry-point <my-entry-point> \
--runtime python37 \
--trigger-http \
--region=asia-east2 \
--memory=8192 \
--timeout=540

错误信息:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: 
/layers/google.python.pip/pip/bin/python3: Error while finding module specification for 'pip' 
(AttributeError: module '__main__' has no attribute '__file__'); Error ID: 99f2b037

源码结构:

.
├── lib
│   ├── __init__.py
│   └── azsync.py
├── main.py
└── requirements.txt

Requirements.txt:

flask==1.0
gcsfs==0.4.0
pandas==0.25.0
azure-storage-blob==12.0.0

【问题讨论】:

标签: python pip google-cloud-functions gcloud


【解决方案1】:

setuptools 60.3.0 的发布导致了 AttributeError,因为 bug 和现在的 Setuptools 60.3.1 is available。可以参考GitHub链接here。

有关更多信息,您可以参考stackoverflow answer:

如果您在 Cloud Function 中遇到此 pip 错误,您可能会考虑更新“requirements.txt”中的 pip,但如果您处于如此不稳定的 Cloud Function 中,更好的解决方法似乎是创建一个新的 Cloud Function 并复制那里的所有内容。

pip 错误可能只是表明源脚本(在本例中为 requirements.txt)无法运行,因为源代码不再完全嵌入或在 Google 存储中丢失了一些嵌入。 或者你给那个云函数第二次机会并编辑,转到源选项卡,单击下拉源代码以选择内联编辑器并手动添加 main.py 和 requirements.txt(运行时:Python)。”

【讨论】:

  • @EEEEH 发了答案,有用吗?
【解决方案2】:

使用提供的 requirements.txt 和 gcloud deploy 命令,我部署了一个示例 Cloud Function,它运行良好。

所以,我认为问题在于您的 .py 代码文件之一。

要进一步排除故障,您可以访问以下 URL:

https://console.cloud.google.com/cloud-build/builds;region=asia-east2?project=

然后选择失败的 Build 浏览其日志,详细查看错误信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-21
    • 1970-01-01
    • 2020-09-03
    • 2019-01-24
    • 2020-01-03
    • 2017-12-23
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多