4

I am trying to install cartopy on a Windows machine, and have previously installed QGIS and GEOS through OSGeo4W64. Now, when I try installing cartopy, I get the following error:

fatal error: 'geos_c.h' file not found

As mentioned, GEOS does exist and the file is also to be found within the directory. I the tried giving Pip the absolute path to the library as a global option, as follows:

pip install --global-option="-Lc:\OSGeo4W64\include"

This, unfortunately didn't work because Pip didn't recognise the -L library option:

error: option -L not recognized.

I tried -I, -l, and -i as well, just to see what would happen, but I get the same error every time. I also found examples on how to give paths to global-option and they did use -L and -I without problems. What could I be doing wrong?

Any help would be greatly appreciated.

borizzzzz
  • 620
  • 1
  • 6
  • 17
  • Can you run with `--no-clean` and see where your build fails (like noted [here](https://stackoverflow.com/a/24186785/515948))? – Laur Ivan Jul 24 '17 at 09:33
  • Thanks for the comment, @LaurIvan . I do get quite a lot of files in the Temp folder but don't know what I should be looking at exactly... – borizzzzz Jul 24 '17 at 10:04

1 Answers1

1

It depends where you get your GEOS from as to which GEOS header file you should be linking against. If you get it from Christoph Gohlke's excellent binaries, or conda-forge, enthought, or Anaconda, I believe all rename geos_c.h to geos.h. If you get it from other sources, it may be that that renaming doesn't take place.

You can see how conda-forge build cartopy on Windows at https://github.com/conda-forge/cartopy-feedstock/blob/master/recipe/. The two important files:

Notice how that latter patch file renames the header dependency to geos.h, rather than geos_c.h because it is using the GEOS packaged by conda-forge. You may need to do a similar thing in your situation.

A history on this subject can also be found at https://github.com/SciTools/conda-recipes-scitools/issues/29#issuecomment-66497972.

pelson
  • 21,252
  • 4
  • 92
  • 99
  • Thank you @pelson, for your helpful answer. I used Anaconda to install cartopy, which worked, but still it does not answer the question why the pip installation fails, especially because the geos_c.h file does exist. Further, the cartopy package was then added to the Anaconda site-packages, and not found by QGIS. I had to manually move the package to the folder QGIS uses, which is not optimal... – borizzzzz Jul 24 '17 at 13:04