繁体   English   中英

导入错误:ApacheBeam 上没有名为“google.cloud”的模块

[英]Import Error: No module named 'google.cloud' on ApacheBeam

I get an import error with importing apache beam's google datastore api.I have one version of Python 3 installed on my Windows 10 64-bit system.

有人可以帮助我吗? 我试图解决它,但我不能

# -*- coding: utf-8 -*-
import apache_beam as beam
from apache_beam.io.gcp.datastore.v1new.datastoreio import ReadFromDatastore, WriteToDatastore
from apache_beam.options.pipeline_options import GoogleCloudOptions
from apache_beam.options.pipeline_options import PipelineOptions

我的错误信息是这样的

Traceback (most recent call last):
  File "C:\Work\test.py", line 3, in <module>
    from apache_beam.io.gcp.datastore.v1new.datastoreio import ReadFromDatastore, WriteToDatastore
  File "C:\Work\VENV\venv\lib\site-packages\apache_beam\io\gcp\datastore\v1new\datastoreio.py", line 40, in <module>
    from apache_beam.io.gcp.datastore.v1new import helper
  File "C:\Work\VENV\venv\lib\site-packages\apache_beam\io\gcp\datastore\v1new\helper.py", line 33, in <module>
    from google.cloud import environment_vars
ModuleNotFoundError: No module named 'google.cloud'

这是 pip 列表

Package                  Version
------------------------ ----------
apache-beam              2.17.0
avro-python3             1.9.1
cachetools               4.0.0
certifi                  2019.11.28
chardet                  3.0.4
crcmod                   1.7
dill                     0.3.0
docopt                   0.6.2
fastavro                 0.21.24
future                   0.18.2
google-api-core          1.16.0
google-api-python-client 1.7.11
google-auth              1.10.1
google-auth-httplib2     0.0.3
googleapis-common-protos 1.51.0
grpcio                   1.26.0
hdfs                     2.5.8
httplib2                 0.12.0
idna                     2.8
mock                     2.0.0
numpy                    1.18.1
oauth2client             3.0.0
pbr                      5.4.4
pip                      19.0.3
protobuf                 3.11.2
pyarrow                  0.15.1
pyasn1                   0.4.8
pyasn1-modules           0.2.8
pydot                    1.4.1
pymongo                  3.10.1
pyparsing                2.4.6
python-dateutil          2.8.1
pytz                     2019.3
requests                 2.22.0
rsa                      4.0
setuptools               40.8.0
six                      1.14.0
uritemplate              3.0.1
urllib3                  1.25.7

请帮我解决我的问题。 之前谢谢

我安装了 apache-beam[gcp] 并且运行得非常好。

缺少“google-cloud”-Pacakge。

跑:

pip install google-cloud

您需要在 ApacheBeam 上为您的选项添加“--requirements_file”标志。

如下

options = MyOptions(flags = ["--requirements_file", "./requirements.txt"])

我面临着同样的问题。 但后来问题已通过以下步骤解决:

  1. 阅读下面关于 virtualenv 的好文章,这将有助于后面的步骤,

  2. 创建虚拟环境(venv env)

  3. 激活虚拟环境

  4. 使用以下链接安装 cloud-dataflow:(这会引入 apache_beam) https://cloud.google.com/dataflow/docs/quickstarts/quickstart-python

  5. 运行示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM