ImportError:无法导入名称'firestore'

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

我正在做一个将在Firestore中编写的数据流流应用程序,当我在DirectRunner上运行时,它可以工作,但是当我在DataflowRunner上运行时,则无法工作。有什么错误?我的requirements.txt是:

apache-beam[gcp,test]==2.19.0
google-cloud-pubsub
google-cloud-firestore==0.29.0

抛出异常的代码行是:

from google.cloud import firestore
db = firestore.Client(project=project)
python-3.x google-cloud-firestore streaming google-cloud-dataflow
1个回答
1
投票

这在“数据流常见问题”中有说明,有几种解决方法

  1. 在函数定义内使用import语句
  2. 在管道选项中将save_main_session设置为True
  3. 定义依赖关系,并使用requirements.txt和setup.py文件适当地组织文件夹结构

可在此处找到更多详细信息-https://cloud.google.com/dataflow/docs/resources/faq#how_do_i_handle_nameerrors

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