为什么在尝试读取 geopanda 包含的数据集中的文件时会出现错误?

Fer*_*ndo 6 python shapely conda geopandas

我刚刚在我的新笔记本电脑中安装了 Anaconda,并创建了一个安装了 geopandas 的环境。我尝试通过以下代码上传geopandas附带的世界地图:

import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误消息:

File ~/anaconda3/envs/mapas_test/lib/python3.8/site-packages/shapely/geometry/base.py:854, in BaseMultipartGeometry.__array_interface__(self)
    851 @property
    852 def __array_interface__(self):
    853     """Provide the Numpy array protocol."""
--> 854     raise NotImplementedError("Multi-part geometries do not themselves "
    855                               "provide the array interface")

NotImplementedError: Multi-part geometries do not themselves provide the array interface
Run Code Online (Sandbox Code Playgroud)

由于我的旧笔记本电脑上从未出现过此错误,我猜这与安装过程中的某些问题有关,但我可能是错的。以下是有关安装的技术细节。

操作系统:Ubuntu 22.04.1

Python版本:3.9.12

康达版本4.13.0

geopandas 版本 0.9.0

匀称版本1.7.1

不确定它是否相关,但环境中安装的唯一其他软件包是 jupyter 版本 1.0.0

mar*_*eis 14

这是由于 shapely 1.7 和 numpy 1.23 不兼容造成的。要么更新shapely到1.8,要么降级numpy,否则不起作用。

  • @Fernando“conda-forge”频道有更新版本的“shapely”。当从 Conda Forge 混合时,“anaconda”通道总是滞后并产生问题。许多用户干脆完全避开“anaconda”频道。 (2认同)