【发布时间】:2016-11-29 01:31:12
【问题描述】:
在 Google Dataproc 上启动 Jupyter Notebook 时,导入模块失败。我尝试使用不同的命令安装模块。一些例子:
import os
os.sytem("sudo apt-get install python-numpy")
os.system("sudo pip install numpy") #after having installed pip
os.system("sudo pip install python-numpy") #after having installed pip
import numpy
以上示例均无效并返回导入错误:
使用命令行时,我可以安装模块,但导入错误仍然存在。我想我在错误的位置安装了模块。
有什么想法吗?
【问题讨论】:
-
如何在 Cloud Dataproc 上安装 Jupyter?您使用的是 Jupyter 初始化操作 (github.com/GoogleCloudPlatform/dataproc-initialization-actions/…) 还是其他方式?
-
我使用了 github 上描述的初始化操作。我尝试了 Jupyter 和 Jupyter 以及 conda-bootstrap 的初始化操作。两者都有相同的问题。注意:我使用的是 PySpark 内核。也许我将模块安装在错误的位置? Jupyter 中使用的 python (pyspark) 的路径是什么?如何安装此版本的模块?我的 gcloud 创建命令:
-
gcloud dataproc clusters create test --zone=europe-west1-d --master-machine-type n1-standard-2 --master-boot-disk-size 100 --num-workers 2 --worker-machine-type n1-standard-2 --worker-boot-disk-size 50 --project myproject --bucket mybucket --initialization-actions gs://dataproc-initialization-actions/jupyter/jupyter.sh -
使用
os.system("sudo apt-get install python-pip -y")和os.system("sudo pip install numpy")时,两行都返回0,表示执行成功。仍然 import numpy 返回相同的导入错误。
标签: python importerror jupyter-notebook google-cloud-dataproc