我在尝试使用库 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/