“Build failed while deploying cloud function.”

huangapple go评论68阅读模式
英文:

Build failed while deploying cloud function

问题

我有一个用Python编写的代码,用于将文件从一个存储桶移动到另一个存储桶。然而,我无法部署这段代码。

以下是我的 requirements.txt 文件:

google-cloud-storage
zipfile
datetime
os

还有我的 main.py 文件:

from google.cloud import storage
import zipfile
import datetime
import os

'google-cloud-storage' 包已经存在,但我的部署仍然失败。有人可以帮助我解决这个问题吗?

英文:

I have a python code to move files from one bucket to another bucket. However, I can't able to deploy the code.

“Build failed while deploying cloud function.”

This is my requirements.txt

google-cloud-storage
zipfile
datetime
os

And my main.py

from google.cloud import storage
import zipfile
import datetime
import os

The 'google-cloud-storage' package is already exists but still my deployment is failing. Can anyone help me to resolve this issue?

答案1

得分: 2

有时候包已经存在,我们会收到这个错误,所以尝试看看是否可以导入它或不行。

正如John Henley在评论中建议的那样,您无需手动指定zipfileZipfilePython标准库中。在main.py中执行import zipfile应该可以正常工作。还要像John在评论中建议的那样从requirements.txt文件中删除datetimeos

确保运行pip install -r requirements.txt命令以安装所有所需的包。

英文:

You know, sometimes the package already exists and we receive this error, so try to see whether you can import it or not.

As John Henley suggested in the comment, you need not to specify the zipfile manually. Zipfile is in the python standard library. import zipfile in main.py should work fine. Also remove datetime and os from requirements.txt file as john suggested already in the comment.

Make sure you run the pip install -r requirements.txt command to install all the required packages.

huangapple
  • 本文由 发表于 2023年6月26日 14:02:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76553890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定