用于 Python 的 Firebase-admin sdk 引发错误“StreamGenerator”不可迭代

问题描述 投票:0回答:1

之前(一周前)我与 Firestore 通信的 Python 代码工作得很好。但今天我又开始研究它,它在迭代

collection.stream()

时引发错误
    service_account = credentials.Certificate('credential/serviceAccount.json')
    firebase_admin.initialize_app(service_account)

    firestore_db = firestore.client()

    docs = firestore_db.collection("FeatureCollection").stream()
    for doc in docs:
        print(doc)

错误出现在

for doc in *docs*
。 错误是
"StreamGenerator" is not iterable "__next__" method not defined on type "DocumentSnapshot"

此外,每当我执行文档请求时,例如

doc = firestore_db.collection("FeatureCollection").document("geom1").get()

它还引发了关于 gRPC 的错误,我根本不熟悉。

# Error
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1721882710.133005 19720588 config.cc:230] gRPC experiments enabled: call_status_override_on_cancellation, event_engine_dns, event_engine_listener, http2_stats_fix, monitoring_experiment, pick_first_new, trace_record_callops, work_serializer_clears_time_cache
I0000 00:00:1721882710.140969 19720588 check_gcp_environment_no_op.cc:29] ALTS: Platforms other than Linux and Windows are not supported
python google-cloud-firestore firebase-admin
1个回答
0
投票

找到解决方案了,和这个问题一样。

我必须设置一些环境变量:

export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1

export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1

© www.soinside.com 2019 - 2024. All rights reserved.