簡體   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