python - AttributeError ("module ' apache_beam.io.gcp.internal.clients.storage'没有属性 'StorageV1'“)

标签 python google-cloud-platform google-cloud-storage apache-beam

我在尝试使用库 apache_beam.io.gcp.gcsfilesystem 时收到此错误。我想使用函数copy()。

我尝试了一个简单的例子:

from apache_beam.io.gcp.gcsfilesystem import GCSFileSystem
GCSFileSystem(pipeline_options = None).copy(source_file_names = image_urls, destination_file_names = destination_urls)

问题是否可能是由于没有传递管道选项造成的?或者可能缺少什么库,因为其他所有使用 apache beam 的库和 GCP API 都工作正常。

最佳答案

StorageV1来自 Beam Python SDK 本身的内部模块。无论您是否安装了 GCP 依赖项,此属性的存在都无关紧要。

您可以通过以下方式检查模块:

>>> from apache_beam.io.gcp.internal.clients import storage
>>> storage.StorageV1
<class 'apache_beam.io.gcp.internal.clients.storage.storage_v1_client.StorageV1'>
>>> vars(storage)
Outputs attributes of this module.

你是如何安装 apache-beam 的?是来自源代码吗?源代码是否已损坏?

您还可以尝试从存储包中导入init.py:

from apitools.base.py import *
from apache_beam.io.gcp.internal.clients.storage.storage_v1_client import *
from apache_beam.io.gcp.internal.clients.storage.storage_v1_messages import *

查看是否抛出任何可能影响您的打包的 ImportError,因为 ImportError 被抑制 here 。很有可能 google-apitools 依赖项未安装,因此打包失败。在这种情况下,您需要安装 apache-beam[gcp] 来确保您具有所需的依赖项。

关于python - AttributeError ("module ' apache_beam.io.gcp.internal.clients.storage'没有属性 'StorageV1'“),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71047065/

相关文章:

mysql - 谷歌云 SQL 存储使用率高问题

python - 如何在Python中从谷歌云存储中的非默认存储桶读取

java - 我应该保持与谷歌云存储的开放连接吗?

google-cloud-storage - gsutil 是否支持使用服务帐号信息创建 boto 文件?

python - 如何使用 tweepy 和 python 获取给定推文的回复?

Python 匹配路径中的字符串并替换为先前的路径项

python - 在 python 2.7 中将图像添加到 Tkinter 的文本小部件

python - 如何检查特定整数是否在列表中

python-3.x - 如何从 Dataflow 批量(有效)发布到 Pub/Sub?

javascript - 检查文件是否从 GCS 在 GCF 中的 temp 中下载