google.cloud import storage: 无法导入 storage

7 浏览
0 Comments

google.cloud import storage: 无法导入 storage

我尝试按照我在这里找到的谷歌教程运行下面的代码:https://cloud.google.com/docs/authentication/production

def implicit():
    from google.cloud import storage
    # 如果在构建客户端时没有指定凭据,客户端库将在环境中查找凭据。
    project = 'my_project_name'
    storage_client = storage.Client(project=project)
    # 进行经过身份验证的 API 请求
    buckets = list(storage_client.list_buckets())
    print(buckets)
implicit()

但是它一直给我报以下错误:

Traceback (most recent call last):
  File "[PATH]/scratch_5.py", line 13, in 
    implicit()
  File "[PATH]/scratch_5.py", line 2, in implicit
    from google.cloud import storage
ImportError: 无法导入名为storage的模块

有人可以帮我解决这个问题吗?

0