2
votes

I am having several issues when installing pygdal in my Mac OSX El capitan. The procedure is the folowing:

  1. Install GDAL Libraries from http://www.kyngchaos.com/software/frameworks#gdal_complete
  2. pip install gdal

The output is the following:

.
.
.
    extensions/gdal_wrap.cpp:3085:10: fatal error: 'cpl_port.h' file not found

    #include "cpl_port.h"
         ^
2 warnings and 1 error generated.
error: command 'cc' failed with exit status 1

Looks like the installer cannot find the GDAL libraries, or headers (libgdal or gdal-devel in ubuntu).

Where are they placed in OSX?

FYI, the following /Library/Frameworks/GDAL.framework/Programs is into the $PATH variable.

2
El Capitan as part of increased security puts system files in different places. A number of mainstream programs have been broken by this. I can not find any file cpl_port.h on my Mac should that help. - Cam_Aust
I did a sudo find / -name cpl_port.h and got this: /Library/Frameworks/GDAL.framework/Versions/1.11/Headers/cpl_port.h /opt/local/include/cpl_port.h. I added those directories to my PATH but I am still getting the same error. - Salias
Hey !!! Sorry..now it worked !!... I put wrong the path int $PATH. - Salias
Easily done. Well, if it also works as a solution to your original question, I suggest write it up as an answer to your own question. - Cam_Aust

2 Answers

4
votes

I finally (with a little help from Cam_Aust) solved the problem !!!

Here is what I did:

  1. Find the cp_port.h file in your system: sudo find / -name cpl_port.h, My output was:

/Library/Frameworks/GDAL.framework/Versions/1.11/Headers/cpl_port.h /opt/local/include/cpl_port.h

  1. Add the resulting folders to your $PATH in your bash init script (~/.bash_login or ~/.zshrc). This worked for me: export PATH=/Library/Frameworks/GDAL.framework/Headers:$PATH
  2. Open a new terminal session or source ~/.zshrc

After this, you can now pip install gdal:

Collecting gdal 
Using cached GDAL-2.1.0.tar.gz
Installing collected packages: gdal
Running setup.py install for gdal ... done
Successfully installed gdal-2.1.0
2
votes

After installing the GDAL Libraries from kyngchaos (as mentioned in the question) you should be able to find the python package ready to go.

I cheated and used that:

export PYTHONPATH=$PYTHONPATH:/Library/Frameworks/GDAL.framework/Versions/2.1/Python/2.7/site-packages