Python无法正常导入

我在Mac OSX上使用Python3.4,并且尝试导入整形.但是,我无法这样做.这是我的回溯:

    from shapely.geometry import Point
  File "/Users/tc9/Library/Python/3.4/lib/python/site-packages/shapely/geometry/__init__.py", line 4, in <module>
    from .base import CAP_STYLE, JOIN_STYLE
  File "/Users/tc9/Library/Python/3.4/lib/python/site-packages/shapely/geometry/base.py", line 9, in <module>
    from shapely.coords import CoordinateSequence
  File "/Users/tc9/Library/Python/3.4/lib/python/site-packages/shapely/coords.py", line 8, in <module>
    from shapely.geos import lgeos
  File "/Users/tc9/Library/Python/3.4/lib/python/site-packages/shapely/geos.py", line 74, in <module>
    _lgeos = load_dll('geos_c', fallbacks=alt_paths)
  File "/Users/tc9/Library/Python/3.4/lib/python/site-packages/shapely/geos.py", line 53, in load_dll
    libname, fallbacks or []))
OSError: Could not find library geos_c or load any of its variants ['/Library/Frameworks/GEOS.framework/Versions/Current/GEOS', '/opt/local/lib/libgeos_c.dylib']

我想可能必须设置GEOS_LIBRARY_PATH,但不确定将其设置为什么.

在我执行brew install geos之后,这是/Users/tc9/homebrew/Cellar/geos/3.4.2/lib的ls:

libgeos-3.4.2.dylib
libgeos.dylib
libgeos_c.a
libgeos.a
libgeos_c.1.dylib
libgeos_c.dylib

我编辑并提供了我的〜/ .profile,但这并不能解决问题:

GEOS_LIBRARY_PATH="/Users/tc9/homebrew/Cellar/geos/3.4.2"
export GEOS_LIBRARY_PATH

有人可以指出我要导入的解决方案的方向吗?谢谢.

解决方法:

您已将homebrew设置为将内容安装在主目录中(当然,主目录中的homebrew子目录中).可以,但是您必须告诉系统在此处找到已安装的库.通常会自动找到/ opt / local / lib,但不会找到/ Users / tc9 / homebrew / lib.

因此,尝试设置DYLD_LIBRARY_PATH而不是设置GEOS_LIBRARY_PATH,如下所示:

export DYLD_LIBRARY_PATH=/Users/tc9/homebrew/lib

您可以先在命令行上执行此操作,如果可行,请将其放入您的配置文件中.

请注意,我没有使用Cellar子目录.您应该将其视为自制软件的存档,而不是实际使用的文件.为此,请使用/ home / tc9 / homebrew(附加lib,bin等).因此,例如,您的PATH也不应包含Cellar目录.

相关文章

最近做自动化测试时,深感自己对前端涉猎太少,加上对这块比...
homebrew本身就是一个git仓库。使用homebrew安装软件包时,会...
一、Homebrew安装、卸载等命令Homebrew的安装和卸载都非常简...
在mac系统中,使用homebrew可以很方便的管理包。按照官网的说...
我按照说明从这里使用brew安装mysqlhttps://gist.github.com...
我在macOS10.12.4上安装了nginx1.10.3和php5.5.38作为开发服...