pythonpipcartopyprojgeos

Cartopy not able to Identify GEOS for PROJ install on Windows


I am trying to install Cartopy on Windows. I have installed all the dependencies from their website, however when I go to run

pip install Cartopy

I get:

 Complete output (5 lines):
  setup.py:117: UserWarning: Unable to determine GEOS version. Ensure you have 3.7.2 or later installed, or installation may fail.
    warnings.warn(
  setup.py:166: UserWarning: Unable to determine Proj version. Ensure you have 8.0.0 or later installed, or installation may fail.
    warnings.warn(
  Proj version 0.0.0 is installed, but cartopy requires at least version 8.0.0

I have ran and succesfully completed

pip install proj
pip install geos

Solution

  • Installing Cartopy on Windows using pip is not trivial. Nevertheless, here is a cartopy installation overview using the method that worked for me, specifically for Windows and without using conda.

    1. Start by uninstalling proj, geos, and shapely if they are already installed, otherwise skip to step 2. This will facilitate linking them in later steps. pip uninstall shapely pip uninstall proj pip uninstall geos

    2. Install proj and geos from OSGeo4W. You cannot use pip to install these because pip points to other projects of the same name. Instead, use the OSGeo4W installer: https://trac.osgeo.org/osgeo4w/ Run as admin and use all the default options, including default installation directories (Advanced Install -> Install from Internet -> All Users -> Next -> Direct Connection -> download.osgeo.org). Then search proj, expand Libs and click the top two "skip"s (proj and proj-data) once each to toggle to the latest release. Now search geos, expand Libs again, and toggle the first "skip" (geos) once to the latest version. Then click next, allow the installer to load dependencies, and click next. The installation took ~5 minutes for me. You now have proj and geos installed.

    3. Install shapely from the .whl. You cannot use the method listed in the cartopy install instructions; it fails to link shapely to geos and you will get an error when importing cartopy. Instead, head to https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely https://pypi.org/project/shapely/#files and download the version that suits your python installation (e.g. if you run 64-bit python 3.10, download shapely‑2.0.2‑cp310‑cp310‑win_amd64.whl) Now you can run pip install \{path}\{to}\{whl}\{Shapely_file.whl}

    4. Install cartopy from the .whl. You can download one that suits you here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#cartopy https://pypi.org/project/Cartopy/#files Pick the one that suits your system (e.g. if you run 64-bit python 3.10, download Cartopy‑0.22.0‑cp310‑cp310‑win_amd64.whl) Now you can run pip install \{path}\{to}\{whl}\{Cartopy_file.whl}

    That's it! It took me a long while and sifting through at least a couple dozen "just use conda" threads to figure this out.

    Select relevant discussions: https://github.com/SciTools/cartopy/issues/1471 https://towardsdatascience.com/install-shapely-on-windows-72b6581bb46c

    Note: This answer was initially tested and worked with shapely v1.8.2 and cartopy v0.20.2.