尝试使用命令将 Python 项目部署到 Google Cloud 函数时
gcloud functions deploy my_function --entry-point reply --runtime python38 --trigger-http --allow-unauthenticated
我明白了
Deploying function (may take a while - up to 2 minutes)...⠛
For Cloud Build Stackdriver Logs, visit: https://[...] Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function; Error ID: 5c04ec9c
但我在文件夹中确实有一个 main.py
文件。
我检查了平台,文件 main.py
没有被上传,而文件夹中的文件被上传。
最佳答案
解决方案是从 .gcloudignore
中省略这一行:
#!include:.gitignore
我真的不明白为什么。
我的 .gitignore
是:
.*
*.json
关于google-cloud-platform - 谷歌云功能 : missing main. py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67422201/