How to fix pip cartopy error: “geos_c.h: No such file or directory”


When trying to install cartopy on Linux using e.g. sudo pip3 install cartopy, you see an error message like

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


Install libgeos-dev using

sudo apt -y install libgeos-dev