python-3.x 属性错误:dlsym(RTLD_DEFAULT,Error_GetLastErrorNum):未找到符号

cld4siwp  于 2023-04-22  发布在  Python
关注(0)|答案(4)|浏览(136)

我最近下载了OSMnx软件包来使用街道网络。然而,每当我尝试导入软件包时,它总是给我返回下面的错误。我已经遵循了其他帖子中的人建议的几个步骤,但没有任何变化。如果有人遇到这个问题或知道解决方法,请与我分享。谢谢!

Traceback (most recent call last):
      File "/Users/qle/Documents/OSMnx/test.py", line 1, in <module>
        import osmnx as ox
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/osmnx/__init__.py", line 3, in <module>
        from ._api import *
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/osmnx/_api.py", line 3, in <module>
        from .bearing import add_edge_bearings
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/osmnx/bearing.py", line 9, in <module>
        from . import projection
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/osmnx/projection.py", line 3, in <module>
        import geopandas as gpd
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/geopandas/__init__.py", line 1, in <module>
        from geopandas._config import options  # noqa
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/geopandas/_config.py", line 126, in <module>
        default_value=_default_use_pygeos(),
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/geopandas/_config.py", line 112, in _default_use_pygeos
        import geopandas._compat as compat
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/geopandas/_compat.py", line 202, in <module>
        import rtree  # noqa
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/rtree/__init__.py", line 9, in <module>
        from .index import Rtree, Index  # noqa
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/rtree/index.py", line 6, in <module>
        from . import core
      File "/Users/qle/Library/Python/3.8/lib/python/site-packages/rtree/core.py", line 77, in <module>
        rt.Error_GetLastErrorNum.restype = ctypes.c_int
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
        func = self.__getitem__(name)
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__
        func = self._FuncPtr((name_or_ordinal, self))
    AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found
2uluyalo

2uluyalo1#

您的错误意味着rtreeosmnx的依赖项)无法找到spatialindex
首先,确保安装了spatialindex

brew install spatialindex

下一个问题是rtree只在非常特定的位置检查spatialindex,而brew安装到/opt/homebrew/Cellar
您设置ENV变量并检查这是否是

export SPATIALINDEX_C_LIBRARY='/opt/homebrew/Cellar/spatialindex/1.9.3/lib'

python -c 'import geopandas'

而且应该可以工作。但是,根据您的SpatialIndex和Brew版本,此路径可能会更改。

iovurdzv

iovurdzv2#

这个问题已经解决了,我想分享的情况下,任何人都可以尝试,如果以后遇到同样的问题。在我安装了最新版本的rtree,你可以看到下面,它仍然给我同样的问题

conda install -c ioos rtree=0.9.7

我不得不为我的Mac安装brew包。https://brew.sh
然后我运行了我的朋友Philippe从另一个页面找到的这两行代码
Installing Rtree from libspacialindex to use .clip() in geopandas
https://github.com/gboeing/osmnx/issues/3

brew install spatialindex
pip install rtree

问题已经完全解决了。

qrjkbowd

qrjkbowd3#

这不是一个OSMnx问题-这是一个rtree问题。你可能想直接用rtree GitHub仓库打开一个问题。也就是说,你在OS X上,所以你可能想尝试用rtree安装

conda install -c ioos rtree=0.8.2

我的一些学生有Mac电脑,他们很难用pip安装rtree,但是用conda命令安装成功了。如果你在Windows上,你可以按照下面的说明安装install geopandas and rtree.
reference

lb3vh1jj

lb3vh1jj4#

我只是简单地重新安装了rtree,现在它工作正常:

pip uninstall rtree
pip install rtree

相关问题