Google 云函数构建失败。错误编号:99f2b037

Google Cloud Function Build failed. Error ID: 99f2b037

当我尝试更新代码并重新部署 Google 云功能时构建失败。

部署脚本:

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

由于 bug and now Setuptools 60.3.1 is available. You can refer to the GitHub Link here.

,setuptools 60.3.0 的发布导致了 AttributeError

更多信息您可以参考如:

If you run into this pip error in a Cloud Function, you might consider updating pip in the "requirements.txt" but if you are in such an unstable Cloud Function the better workaround seems to be to create a new Cloud Function and copy everything in there.

The pip error probably just shows that the source script, in this case the requirements.txt, cannot be run since the source code is not fully embedded anymore or has lost some embedding in the Google Storage. or you give that Cloud Function a second chance and edit, go to Source tab, click on Dropdown Source code to choose Inline Editor and add main.py and requirements.txt manually (Runtime: Python).”

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

所以,我认为问题出在您的一个 .py 代码文件上。

要进一步排除故障,您可以转到下面URL:

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

然后 select 失败的构建浏览其日志,并详细查看错误消息。