无法导入cartopy。

4
在Google Colab上安装Cartopy后,我无法导入它:
!pip install cartopy
import cartopy

ImportError: cannot import name lgeos
3个回答

7

是的,通过降级 shapely 库:

pip install shapely==1.8.5

对我有用。 (在Google Colab中)


5

我遇到了相同的问题(未使用 google-colab),这似乎是由于Cartopy/Shapely v2.0兼容性问题引起的:https://github.com/SciTools/cartopy/issues/2076

更多追踪:

import cartopy.trace
  File "lib/cartopy/trace.pyx", line 77, in init cartopy.trace
ImportError: cannot import name lgeos

我使用pip,将Shapely版本明确降级到1.8.5对我有用。


3

在Colab中安装Cartopy的最佳方式是使用Conda环境。因此,我们需要安装以下内容:

#1|Install Conda environment on Colab
!pip install -q condacolab
import condacolab
condacolab.install()

那么,

#2|Install cartopy 
!mamba install -q -c conda-forge cartopy

之后,
#3|imoprt cartopy 
import cartopy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接