Cartopy not able to Identify GEOS for PROJ install on Windows

Question:

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
Asked By: CeilingSystems

||

Answers:

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 and download the version that suits your python installation (e.g. if you run 64-bit python 3.10, download Shapely‑1.8.1.post1‑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 Pick the one that suits your system (e.g. if you run 64-bit python 3.10, download Cartopy‑0.20.2‑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

Answered By: jlave

Do yourself a favour and use conda (or even better mamba) to manage your package-dependencies!

1 line and it will work out of the box in Windows, MacOS and Linux.

conda install -c conda-forge cartopy

Managing dependencies yourself is tedious and error-prone, especially when it comes to c or c++ dependencies (which is the case for geo-libraries such as pyproj or gdal)

… it’s also what cartopy recommends in their docs!

Answered By: raphael

The answer provided by jlave worked great in installing Cartopy.

In order to successfully import Cartopy after its installation, pyproj needed to be installed from the same site as shapely.

If this step is not included I am getting the following error:

ImportError: DLL load failed while importing trace: The specified module could not be found. 

For cartopy.crs and cartopy.trace

Answered By: Aqua_George
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.