英文:
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.
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在评论中建议的那样,您无需手动指定zipfile
。Zipfile在Python标准库中。在main.py
中执行import zipfile
应该可以正常工作。还要像John在评论中建议的那样从requirements.txt
文件中删除datetime
和os
。
确保运行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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论