在HdInsight上使用PySpark3中的其他库

问题描述 投票:0回答:1

我正在尝试安装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上。如何在群集上部署它?

python azure pyspark hdinsight shapely
1个回答
1
投票

由于它是一个spark集群,因此必须在每个节点上安装lib。因此,我需要通过HD Insight界面上的“脚本操作”执行install命令。但是,当我使用虚拟环境时,该命令需要添加-n env选项。

最后运行的命令是:

#!/usr/bin/env bash

/usr/bin/anaconda/bin/conda install -c conda-forge shapely -n py35
© www.soinside.com 2019 - 2024. All rights reserved.