首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google函数:缺少main.py

Google函数:缺少main.py
EN

Stack Overflow用户
提问于 2021-05-06 16:21:21
回答 2查看 5K关注 0票数 3

当尝试使用命令将Python项目部署到Google函数时

gcloud functions deploy my_function --entry-point reply --runtime python38 --trigger-http --allow-unauthenticated

我得到了

部署函数(可能需要2分钟)...⠛

对于日志,请访问:https://[...]部署函数(可能需要2分钟)...failed。

错误:(gcloud.functions.deploy) OperationError: code=3,message=Build failed:缺失main.py和未指定GOOGLE_FUNCTION_SOURCE。要么在main.py中创建函数,要么指定GOOGLE_FUNCTION_SOURCE指向包含函数的文件;错误ID: 5c04ec9c

但我在文件夹中确实有一个main.py文件。

我检查了平台,没有上传文件main.py,而文件夹中的文件是。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-05-06 16:21:21

解决方案是从.gcloudignore中省略这一行

代码语言:javascript
复制
#!include:.gitignore

我不太明白为什么。

我的.gitignore是:

代码语言:javascript
复制
.*
*.json
票数 3
EN

Stack Overflow用户

发布于 2021-09-14 17:31:45

.gcloudignore的内容对我来说很有魅力。我从已经拥有这个自动生成文件的其他项目中复制了它。

FileName:.gcloudignore

代码语言:javascript
复制
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
node_modules
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67422201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档