在Google Colab上安装Cartopy后,我无法导入它:
!pip install cartopy
import cartopy
ImportError: cannot import name lgeos
!pip install cartopy
import cartopy
ImportError: cannot import name lgeos
是的,通过降级 shapely 库:
pip install shapely==1.8.5
对我有用。 (在Google Colab中)
我遇到了相同的问题(未使用 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
对我有用。
在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