15

I am trying to install cartopy via pip install cartopy. I have installed proj.4 and it has placed a necessary file here

~/Downloads/proj-4.9.2 $ ls -l /usr/local/include/proj_api.h -rw-r--r--@ 1 dom admin 5911 Nov 21 11:06 /usr/local/include/proj_api.h

But pip install is not finding it:

gcc -fno-strict-aliasing -I/Applications/SageMath/local/var/tmp/sage/build/python2-2.7.10.p2/include -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -I/Applications/SageMath/local/include -I./lib/cartopy -I/usr/local/Cellar/geos/3.5.0/include -I/Applications/SageMath/local/include/python2.7 -c lib/cartopy/trace.cpp -o build/temp.macosx-10.9-x86_64-2.7/lib/cartopy/trace.o lib/cartopy/trace.cpp:282:22: fatal error: proj_api.h: No such file or directory #include "proj_api.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1

How do I get something like -I/usr/local/include to appear in the above gcc command? Somehow -I/usr/local/Cellar/geos/3.5.0/include gets put there.

idontgetoutmuch
  • 1,613
  • 11
  • 17

2 Answers2

26

This will do the trick :)

sudo apt-get install libproj-dev

  • 3
    While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – DimaSan Feb 27 '17 at 17:35
  • 1
    Cartopy [install docs](https://scitools.org.uk/cartopy/docs/v0.15/installing.html#requirements) state a dependency on PROJ.4, which has 2 parts -- the python bindings and the C backend. `pip install pyproj` for the python bit, `apt install libproj-dev` for the C bit. – Bonlenfum May 21 '18 at 09:52
  • @Bonlenfum Hi I am trying to install Cartopy, but I am running into the same issues as above. How do I actually run the second bit of code you listed? I'm on Windows and keep getting an error when I type that into the command line. – Eli Turasky Feb 07 '20 at 22:50
  • @EliTurasky `apt install` is a command for debian-based linux OS. You coul try conda, as suggested by the cartopy docs (link I posted before still works), or if the only dependency that doesn't work for you is PROJ, try OSGeo4W as suggested by the [proj installation docs](https://proj.org/install.html#windows). – Bonlenfum Jun 22 '20 at 10:49
2

export CFLAGS="-I/usr/local/include" seems to do the trick.

idontgetoutmuch
  • 1,613
  • 11
  • 17