【发布时间】:2016-10-12 06:22:31
【问题描述】:
我只是想使用演示代码。我在 Jupyter Notebook 中运行以下命令:
from shapely.geometry import shape
这给了我以下信息:
OSError Traceback (most recent call last)
<ipython-input-4-cf5b4d0962ea> in <module>()
----> 1 from shapely.geometry import shape
/Users/hkwik/anaconda/lib/python2.7/site-packages/shapely/geometry/__init__.py in <module>()
2 """
3
----> 4 from .base import CAP_STYLE, JOIN_STYLE
5 from .geo import box, shape, asShape, mapping
6 from .point import Point, asPoint
/Users/hkwik/anaconda/lib/python2.7/site-packages/shapely/geometry/base.py in <module>()
7 from ctypes import pointer, c_size_t, c_char_p, c_void_p
8
----> 9 from shapely.coords import CoordinateSequence
10 from shapely.ftools import wraps
11 from shapely.geos import lgeos, ReadingError
/Users/hkwik/anaconda/lib/python2.7/site-packages/shapely/coords.py in <module>()
6 from ctypes import byref, c_double, c_uint
7
----> 8 from shapely.geos import lgeos
9 from shapely.topology import Validating
10
/Users/hkwik/anaconda/lib/python2.7/site-packages/shapely/geos.py in <module>()
81 _lgeos = load_dll('geos_c', fallbacks=alt_paths)
82
---> 83 free = load_dll('c').free
84 free.argtypes = [c_void_p]
85 free.restype = None
/Users/hkwik/anaconda/lib/python2.7/site-packages/shapely/geos.py in load_dll(libname, fallbacks, mode)
59 raise OSError(
60 "Could not find lib {0} or load any of its variants {1}.".format(
---> 61 libname, fallbacks or []))
62
63 _lgeos = None
OSError: Could not find lib c or load any of its variants [].
但是,如果我从解释器运行,一切都很好。
知道发生了什么吗?
【问题讨论】:
-
您是否尝试过任何解决方案?看起来像是 OSX 独有的问题,Github 上有两个问题:github.com/carsonfarmer/python_geospatial/issues/… & github.com/Toblerity/Shapely/issues/394#issuecomment-235163776
-
你使用虚拟环境吗?你是如何安装jupyter的?标准?
-
不得不说@chrki 评论看起来就是答案——你试过@Huey 吗?
-
可能重复stackoverflow.com/questions/19742406/…需要安装libgeos-c1 libgeos-3.4.2 libgeos-dev包