无法在 Python 中导入 shapely.geometry [英] Cannot import shapely.geometry in Python

查看:112
本文介绍了无法在 Python 中导入 shapely.geometry的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 IPython 笔记本中的 shapely.geometry 导入多点.

I am trying to import Multipoint from shapely.geometry in IPython notebook.

当我执行from shapely.geometry import MultiPoint"时,出现错误No module named shapely.geometry".

When I do "from shapely.geometry import MultiPoint", I get the error "No module named shapely.geometry".

所以,我尝试执行!pip install --upgrade shapely",为此我得到了错误

So, I tried doing "!pip install --upgrade shapely", for this I get the error

Running setup.py (path:/tmp/pip-build-NyZFjW/shapely/setup.py) egg_info for package shapely
Failed `CDLL(libgeos_c.so.1)`
Failed `CDLL(libgeos_c.so)`
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/tmp/pip-build-NyZFjW/shapely/setup.py", line 38, in <module>
    from shapely._buildcfg import geos_version_string, geos_version, \
  File "shapely/_buildcfg.py", line 167, in <module>
    fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
  File "shapely/_buildcfg.py", line 161, in load_dll
    libname, fallbacks or []))
OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
Complete output from command python setup.py egg_info:
Failed `CDLL(libgeos_c.so.1)`

我需要找到使用 DBSCAN 算法形成的每个集群的集群质心.只有解决了这个问题,才能做到这一点.

I need to find my cluster centroids of each cluster that's formed using DBSCAN Algorithm. That can be done only if this issue is resolved.

任何帮助将不胜感激.

推荐答案

我在您的输出中发现了这个 OSError:

I had this OSError that I found in your output:

Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']

要解决我安装了 lib-geos 的问题,请运行:

To solve that I installed the lib-geos, by running:

$ sudo apt-get install libgeos-dev

这篇关于无法在 Python 中导入 shapely.geometry的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆