GCP功能' google.cloud.storage'。模块没有属性' client'

发布于 2025-02-11 02:19:46 字数 700 浏览 0 评论 0原文

我正在使用Google Cloud功能中的Python 3.8版本,需要将文件存储在我编写的脚本中的存储中。但是我无法创建存储客户端对象。

这是我的代码:

from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('bucket_name')
blob = bucket.blob("dataframe.csv")
blob.upload_from_string(dataframe.to_csv(index=False))

此代码中的一些以及使用HTTP触发器运行功能时会遇到的错误:

storage_client = storage.Client() AttributeError: 'Storage' object has no attribute 'Client'

它们已安装在unignts.txt文件中

google-cloud-storage
google-api-python-client
google-auth-httplib2 
google-auth-oauthlib
oauth2client
argparse
pandas
opentelemetry-api
opentelemetry-instrumentation 

I am working with python 3.8 version in Google Cloud Functions and I need to store the file in the storage in the script I wrote. But I can't create storage client object.

This is my code:

from google.cloud import storage
storage_client = storage.Client()
bucket = storage_client.get_bucket('bucket_name')
blob = bucket.blob("dataframe.csv")
blob.upload_from_string(dataframe.to_csv(index=False))

some of this code and the error I get when I run it in functions with HTTP trigger:

storage_client = storage.Client() AttributeError: 'Storage' object has no attribute 'Client'

they are installed in the requirements.txt file

google-cloud-storage
google-api-python-client
google-auth-httplib2 
google-auth-oauthlib
oauth2client
argparse
pandas
opentelemetry-api
opentelemetry-instrumentation 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文