在HdInsight上使用PySpark3中的其他库

时间:2017-12-14 09:41:14

标签: python azure pyspark hdinsight shapely

我正在尝试安装Shapely库,但是当我导入它时,收到错误消息:

> from shapely.geometry import Point
No module named 'shapely'
Traceback (most recent call last):
ImportError: No module named 'shapely' 

我的内核是:

cat /usr/local/share/jupyter/kernels/pyspark3kernel/kernel.json
{"argv":["python","-m","sparkmagic.kernels.pyspark3kernel.pyspark3kernel", "-f", "{connection_file}"],
 "display_name":"PySpark3"
}

我检查了我的其他库的安装位置:

> import pandas 
> pandas.__file__
'/usr/bin/anaconda/envs/py35/lib/python3.5/site-packages/pandas/__init__.py'

Shapely安装在同一个文件夹中:

/usr/bin/anaconda/envs/py35/lib/python3.5/site-packages$ ls *hapely*
shapely:
affinity.py  _buildcfg.py  ctypes_declarations.py  examples   geometry   geos.py  __init__.py  linref.py  predicates.py  __pycache__  strtree.py   validation.py  wkb.py
algorithms   coords.py     errors.py               ftools.py  _geos.pxi  impl.py  iterops.py   ops.py     prepared.py    speedups     topology.py  vectorized     wkt.py

Shapely-1.6.3.dist-info:
DESCRIPTION.rst  INSTALLER  METADATA  metadata.json  RECORD  top_level.txt  WHEEL

仅供参考,我的火花在HD Insight群集上。

我应该怎么做或检查修复此库?如果您需要更多详细信息,请告诉我们。

修改

我刚发现

%%local
from shapely.geometry import Point

工作得非常好......因此,我认为我的lib没有安装在集群上,而是安装在localy上。如何在群集上部署它?

1 个答案:

答案 0 :(得分:1)

由于它是一个spark集群,因此必须在每个节点上安装lib。 因此,我需要通过"脚本操作"执行安装命令。在HD Insight界面上。 但是,当我使用虚拟环境时,该命令需要添加char * strtok ( char * str, const char * delimiters ); 选项。

最后运行的命令是:

-n env