如何修复 pip cartopy error: geos_c.h No such file or directory

问题:

尝试在 Linux 上使用例如 pip install -U cartopy 安装 cartopy 时,你看到类似这样的错误消息

cartopy_trace.txt
lib/cartopy/trace.cpp:633:10: fatal error: geos_c.h: Datei oder Verzeichnis nicht gefunden
    633 | #include "geos_c.h"
        |          ^~~~~~~~~~
compilation terminated.
setup.py:117: UserWarning: Unable to determine GEOS version. Ensure you have 3.3.3 or later installed, or installation may fail.

解决方案

使用以下命令安装 libgeos-dev

install_libgeos_dev.sh
sudo apt -y install libgeos-dev

Check out similar posts by category: Cartopy, Python