'Google Cloud Function Build failed. Error ID: 99f2b037

Build failed when I try to update code and re-deploy the Google Cloud Function.

Deploy Script:

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

Error Message:

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

Source code structure:

.
├── 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


Solution 1:[1]

With the provided requirements.txt and the gcloud deploy command, I deployed a sample Cloud Function, and it worked fine.

So, I believe the issue is with one of your .py code files.

To troubleshoot further, you can go to the below URL:

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

And then select the failed Build to browse its logs, and view the error message in detail.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gourav B