Cannot import shapely.geometry in Python

拈花ヽ惹草 提交于 2019-12-12 04:28:50

问题


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

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

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)`

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.

Any help would be greatly appreciated.


回答1:


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']

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

$ sudo apt-get install libgeos-dev



来源:https://stackoverflow.com/questions/40642544/cannot-import-shapely-geometry-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!