You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入geopandas触发AttributeError错误的排查与解决

导入geopandas时出现AttributeError: undefined symbol: Error_GetLastErrorNum的解决方法

截至本周初仍可正常使用geopandas包,今日执行导入操作:

import geopandas

触发以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib/python3.10/site-packages/geopandas/__init__.py", line 1, in <module>
    from geopandas._config import options  # noqa
  File "/home/user/.local/lib/python3.10/site-packages/geopandas/_config.py", line 109, in <module>
    default_value=_default_use_pygeos(),
  File "/home/user/.local/lib/python3.10/site-packages/geopandas/_config.py", line 95, in _default_use_pygeos
    import geopandas._compat as compat
  File "/home/user/.local/lib/python3.10/site-packages/geopandas/_compat.py", line 216, in <module>
    import rtree  # noqa
  File "/home/user/.local/lib/python3.10/site-packages/rtree/__init__.py", line 9, in <module>
    from .index import Rtree, Index  # noqa
  File "/home/user/.local/lib/python3.10/site-packages/rtree/index.py", line 6, in <module>
    from . import core
  File "/home/user/.local/lib/python3.10/site-packages/rtree/core.py", line 77, in <module>
    rt.Error_GetLastErrorNum.restype = ctypes.c_int
  File "/usr/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python3: undefined symbol: Error_GetLastErrorNum

已尝试卸载并重装不同版本的geopandas(当前环境:Python 3.10.6、geopandas 0.11.1),但问题未解决。

解决方法

更新rtree包版本后问题解决。

内容的提问来源于stack exchange,提问作者Syner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 20:45:34