导入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
相关产品推荐
相关产品推荐

