Search code examples
pythonpipgoogle-cloud-functionsgcloud

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

  • The release of setuptools 60.3.0 caused AttributeError because of a bug and now Setuptools 60.3.1 is available. You can refer to the GitHub Link here.

    For more information you can refer to the stackoverflow answer as :

    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).”