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

运行momepy入门代码遇AttributeError: shapely.geos无lgeos属性

解决AttributeError: module 'shapely.geos' has no attribute 'lgeos'

这个错误是Shapely版本不兼容导致的:Shapely 2.0及以上版本重构了内部API,移除了lgeos属性,而你当前环境里的momepy或其依赖库仍在调用这个旧属性。

解决方案步骤:

  • 先检查当前Shapely版本:
    import shapely
    print(shapely.__version__)
    
    或者在终端运行:
    pip show shapely
    
  • 降级Shapely到1.x稳定版本(推荐1.8.5.post1):
    pip install shapely==1.8.5.post1 --force-reinstall
    
  • 重新运行目标代码块:
    f, ax = plt.subplots(figsize=(10, 10))
    buildings.plot(ax=ax)
    ax.set_axis_off()
    plt.show()
    

额外建议

如果后续安装其他地理库时再次触发版本升级,建议使用虚拟环境(如venv、conda环境)隔离momepy项目的依赖,避免不同项目间的版本冲突。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 07:50:34