[英]cannot import name 'dataproc_v1' from 'google.cloud' (unknown location)
Trying to access Using Dataproc via Jupyter Notebook from the computer, I installed required libraries using pip.尝试从计算机通过 Jupyter Notebook 访问 Using Dataproc,我使用 pip 安装了所需的库。 However, getting error while importing
但是,导入时出错
import google.cloud.dataproc_v1
Error is as follows:错误如下:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-fc8862c62c75> in <module>
----> 1 import google.cloud.dataproc_v1
Also tried installing the package python3 -m pip install google-cloud-dataproc.还尝试安装包 python3 -m pip install google-cloud-dataproc。 For reference, here is the output of pip list.
作为参考,这里是 pip list 的输出。 Any suggestion/ help is appreciated!
任何建议/帮助表示赞赏!
Package Version
------------------------ ---------
cachetools 4.1.1
certifi 2020.6.20
chardet 3.0.4
google-api-core 1.22.2
google-auth 1.21.1
google-cloud-dataproc 2.0.0
googleapis-common-protos 1.52.0
grpcio 1.32.0
idna 2.10
libcst 0.3.10
mypy-extensions 0.4.3
pip 20.2.2
proto-plus 1.9.1
protobuf 3.13.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pytz 2020.1
PyYAML 5.3.1
requests 2.24.0
rsa 4.6
setuptools 45.0.0
six 1.15.0
typing-extensions 3.7.4.3
typing-inspect 0.6.0
urllib3 1.25.10
wheel 0.35.1
If you are installing from within the notebook, try this in a cell:如果您是从笔记本中安装,请在单元格中尝试此操作:
! ! pip install google.cloud.dataproc_v1
pip 安装 google.cloud.dataproc_v1
If you get an error due to missing access, try it with --user option, ie如果由于缺少访问权限而出现错误,请尝试使用 --user 选项,即
! ! pip install google.cloud.dataproc_v1 --user
pip 安装 google.cloud.dataproc_v1 --user
Restart the kernel and try importing the library again.重新启动内核并再次尝试导入库。
Can you confirm you are running from a Jupyter notebook on Dataproc and what version of Dataproc?您能否确认您是从 Dataproc 上的 Jupyter notebook 运行的,以及什么版本的 Dataproc?
I have tested the following code running on Dataproc notebook using Dataproc version 1.5我已经使用 Dataproc 1.5 版测试了在 Dataproc 笔记本上运行的以下代码
from google.cloud import dataproc_v1
from google.cloud import storage
project_id = 'project'
region = 'us-central1'
cluster_name = 'cluster'
cluster_client = dataproc_v1.ClusterControllerClient(
client_options={"api_endpoint": "{}-dataproc.googleapis.com:443".format(region)}
)
for cluster in cluster_client.list_clusters(request={"project_id": project_id, "region": region}):
cluster_name = cluster.cluster_name
print(f"{cluster_name}")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.