3

I'm trying to install the [GDAL python package][1] on a Mac (OSX Yosemite) with python 2.7.9 and GDAL 1.11.3. When I try $ sudo easy_install GDAL I get a number of errors ending with:

error: Setup script exited with error: command 'gcc' failed with exit status 1

The full error log is below. I was wondering if anyone could point out what the issue(s) may be and how to fix them.

FULL ERROR MESSAGE:

Searching for GDAL
Reading https://pypi.python.org/simple/GDAL/
Best match: GDAL 2.0.1
Downloading https://pypi.python.org/packages/source/G/GDAL/GDAL-2.0.1.tar.gz#md5=df013c4417a3820b6d59c9b01d2c68c9
Processing GDAL-2.0.1.tar.gz
Writing /tmp/easy_install-tKnmjc/GDAL-2.0.1/setup.cfg
Running GDAL-2.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tKnmjc/GDAL-2.0.1/egg-dist-tmp-SGCc8W
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future';
      did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
warning: unknown warning option '-Werror=unused-command-line-argument-hard-error-in-future';
      did you mean '-Werror=unused-command-line-argument'? [-Wunknown-warning-option]
extensions/gdal_wrap.cpp:4265:47: error: use of undeclared identifier
      'GDALDatasetCreateLayer'; did you mean 'GDALDatasetShadow_CreateLayer'?
    OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetCreateLayer( self,
                                              ^~~~~~~~~~~~~~~~~~~~~~
                                              GDALDatasetShadow_CreateLayer
extensions/gdal_wrap.cpp:4264:28: note: 'GDALDatasetShadow_CreateLayer' declared here
SWIGINTERN OGRLayerShadow *GDALDatasetShadow_CreateLayer(GDALDatasetShadow *self,cha...
                           ^
extensions/gdal_wrap.cpp:4273:47: error: use of undeclared identifier 'GDALDatasetCopyLayer'
    OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetCopyLayer( self,
                                              ^
extensions/gdal_wrap.cpp:4280:12: error: use of undeclared identifier
      'GDALDatasetDeleteLayer'; did you mean 'GDALDatasetShadow_DeleteLayer'?
    return GDALDatasetDeleteLayer(self, index);
           ^~~~~~~~~~~~~~~~~~~~~~
           GDALDatasetShadow_DeleteLayer
extensions/gdal_wrap.cpp:4279:19: note: 'GDALDatasetShadow_DeleteLayer' declared here
SWIGINTERN OGRErr GDALDatasetShadow_DeleteLayer(GDALDatasetShadow *self,int index){
                  ^
extensions/gdal_wrap.cpp:4306:8: error: use of undeclared identifier
      'OGRERR_NON_EXISTING_FEATURE'
  case OGRERR_NON_EXISTING_FEATURE:
       ^
extensions/gdal_wrap.cpp:4314:12: error: use of undeclared identifier
      'GDALDatasetGetLayerCount'; did you mean 'GDALDatasetShadow_GetLayerCount'?
    return GDALDatasetGetLayerCount(self);
           ^~~~~~~~~~~~~~~~~~~~~~~~
           GDALDatasetShadow_GetLayerCount
extensions/gdal_wrap.cpp:4313:16: note: 'GDALDatasetShadow_GetLayerCount' declared here
SWIGINTERN int GDALDatasetShadow_GetLayerCount(GDALDatasetShadow *self){
               ^
extensions/gdal_wrap.cpp:4318:47: error: use of undeclared identifier 'GDALDatasetGetLayer'
    OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetGetLayer(self, index);
                                              ^
extensions/gdal_wrap.cpp:4322:47: error: use of undeclared identifier
      'GDALDatasetGetLayerByName'; did you mean 'GDALDatasetShadow_GetLayerByName'?
    OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetGetLayerByName(self, layer_name);
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
                                              GDALDatasetShadow_GetLayerByName
extensions/gdal_wrap.cpp:4321:28: note: 'GDALDatasetShadow_GetLayerByName' declared here
SWIGINTERN OGRLayerShadow *GDALDatasetShadow_GetLayerByName(GDALDatasetShadow *self,c...
                           ^
extensions/gdal_wrap.cpp:4326:13: error: use of undeclared identifier
      'GDALDatasetTestCapability'; did you mean 'GDALDatasetShadow_TestCapability'?
    return (GDALDatasetTestCapability(self, cap) > 0);
            ^~~~~~~~~~~~~~~~~~~~~~~~~
            GDALDatasetShadow_TestCapability
extensions/gdal_wrap.cpp:4325:17: note: 'GDALDatasetShadow_TestCapability' declared here
SWIGINTERN bool GDALDatasetShadow_TestCapability(GDALDatasetShadow *self,char const *cap){
                ^
extensions/gdal_wrap.cpp:4336:47: error: use of undeclared identifier
      'GDALDatasetExecuteSQL'; did you mean 'GDALDatasetShadow_ExecuteSQL'?
    OGRLayerShadow* layer = (OGRLayerShadow*) GDALDatasetExecuteSQL(self,
                                              ^~~~~~~~~~~~~~~~~~~~~
                                              GDALDatasetShadow_ExecuteSQL
extensions/gdal_wrap.cpp:4335:28: note: 'GDALDatasetShadow_ExecuteSQL' declared here
SWIGINTERN OGRLayerShadow *GDALDatasetShadow_ExecuteSQL(GDALDatasetShadow *self,char ...
                           ^
extensions/gdal_wrap.cpp:4343:5: error: use of undeclared identifier
      'GDALDatasetReleaseResultSet'; did you mean 'GDALDatasetShadow_ReleaseResultSet'?
    GDALDatasetReleaseResultSet(self, layer);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    GDALDatasetShadow_ReleaseResultSet
extensions/gdal_wrap.cpp:4342:17: note: 'GDALDatasetShadow_ReleaseResultSet' declared here
SWIGINTERN void GDALDatasetShadow_ReleaseResultSet(GDALDatasetShadow *self,OGRLayerSh...
                ^
extensions/gdal_wrap.cpp:4346:35: error: use of undeclared identifier
      'GDALDatasetGetStyleTable'; did you mean 'GDALDatasetShadow_GetStyleTable'?
    return (OGRStyleTableShadow*) GDALDatasetGetStyleTable(self);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~
                                  GDALDatasetShadow_GetStyleTable
extensions/gdal_wrap.cpp:4345:33: note: 'GDALDatasetShadow_GetStyleTable' declared here
SWIGINTERN OGRStyleTableShadow *GDALDatasetShadow_GetStyleTable(GDALDatasetShadow *self){
                                ^
extensions/gdal_wrap.cpp:4350:9: error: use of undeclared identifier
      'GDALDatasetSetStyleTable'; did you mean 'GDALDatasetShadow_SetStyleTable'?
        GDALDatasetSetStyleTable(self, (OGRStyleTableH) table);
        ^~~~~~~~~~~~~~~~~~~~~~~~
        GDALDatasetShadow_SetStyleTable
extensions/gdal_wrap.cpp:4348:17: note: 'GDALDatasetShadow_SetStyleTable' declared here
SWIGINTERN void GDALDatasetShadow_SetStyleTable(GDALDatasetShadow *self,OGRStyleTable...
                ^
extensions/gdal_wrap.cpp:4350:40: error: cannot initialize a parameter of type
      'OGRStyleTableShadow *' (aka 'OGRStyleTableHS *') with an rvalue of type
      'OGRStyleTableH' (aka 'void *')
        GDALDatasetSetStyleTable(self, (OGRStyleTableH) table);
                                       ^~~~~~~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:4348:94: note: passing argument to parameter 'table' here
  ...GDALDatasetShadow_SetStyleTable(GDALDatasetShadow *self,OGRStyleTableShadow *table){
                                                                                  ^
extensions/gdal_wrap.cpp:4353:12: error: use of undeclared identifier
      'GDALDatasetStartTransaction'; did you mean 'GDALDatasetShadow_StartTransaction'?
    return GDALDatasetStartTransaction(self, force);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
           GDALDatasetShadow_StartTransaction
extensions/gdal_wrap.cpp:4352:19: note: 'GDALDatasetShadow_StartTransaction' declared here
SWIGINTERN OGRErr GDALDatasetShadow_StartTransaction(GDALDatasetShadow *self,int forc...
                  ^
extensions/gdal_wrap.cpp:4356:12: error: use of undeclared identifier
      'GDALDatasetCommitTransaction'; did you mean 'GDALDatasetShadow_CommitTransaction'?
    return GDALDatasetCommitTransaction(self);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
           GDALDatasetShadow_CommitTransaction
extensions/gdal_wrap.cpp:4355:19: note: 'GDALDatasetShadow_CommitTransaction' declared here
SWIGINTERN OGRErr GDALDatasetShadow_CommitTransaction(GDALDatasetShadow *self){
                  ^
extensions/gdal_wrap.cpp:4359:12: error: use of undeclared identifier
      'GDALDatasetRollbackTransaction'; did you mean 'GDALDatasetShadow_RollbackTransaction'?
    return GDALDatasetRollbackTransaction(self);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           GDALDatasetShadow_RollbackTransaction
extensions/gdal_wrap.cpp:4358:19: note: 'GDALDatasetShadow_RollbackTransaction' declared here
SWIGINTERN OGRErr GDALDatasetShadow_RollbackTransaction(GDALDatasetShadow *self){
                  ^
extensions/gdal_wrap.cpp:4361:294: error: unknown type name 'GDALRIOResampleAlg'; did you
      mean 'GDALResampleAlg'?
  ...*buf_line_space=0,GIntBig *buf_band_space=0,GDALRIOResampleAlg resample_alg=GRIORA_Ne...
                                                 ^~~~~~~~~~~~~~~~~~
                                                 GDALResampleAlg
/usr/local/Cellar/gdal/1.11.3/include/gdalwarper.h:56:3: note: 'GDALResampleAlg' declared
      here
} GDALResampleAlg;
  ^
extensions/gdal_wrap.cpp:4361:326: error: use of undeclared identifier
      'GRIORA_NearestNeighbour'; did you mean 'GRA_NearestNeighbour'?
  ...*buf_band_space=0,GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour,GDALProgres...
                                                       ^~~~~~~~~~~~~~~~~~~~~~~
                                                       GRA_NearestNeighbour
/usr/local/Cellar/gdal/1.11.3/include/gdalwarper.h:49:56: note: 'GRA_NearestNeighbour'
      declared here
  /*! Nearest neighbour (select on one input pixel) */ GRA_NearestNeighbour=0,
                                                       ^
extensions/gdal_wrap.cpp:4425:5: error: unknown type name 'GDALRasterIOExtraArg'
    GDALRasterIOExtraArg sExtraArg;
    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
error: Setup script exited with error: command 'gcc' failed with exit status 1


  [1]: https://pypi.python.org/pypi/GDAL/
2

The problem is that with easy_install GDAL, the script try to first install the last version of GDAL (2.0.1) with many errors (answer of Kersten) while what you want are the Python bindings of GDAL 1.11

Therefore, you have to look for and download the Python bindings of GDAL 1.11 and after

CFLAGS=`/path of/gdal-config --cflags` 
LDFLAGS=`/path of /gdal-config --libs
python setup.py install

But, how have you installed GDAL 1.11.3 ? If it is the KyngChaos version (GDAL framework v1.11.3-1), the bindings are in /Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages

And in the Apple Python there is a path file /Library/Python/2.7/site-packages/gdal-py2.7.pth that points to the precedent folder.

import sys; sys.path.insert(0,'/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages')

You can copy and move this file to use the bindings in other Python 2.7.x versions (Homebrew, Anaconda, Framework, ...)

enter image description here

enter image description here

0

If you want to compile GDAL from source you will need to fulfill all its dependencies. Unless you explicitly need to compile it from source I would advise to use a pre-built binary.

On OsX the most popular (and probably easiest) way to install GDAL is via the kyngchaos.com binaries.

Alternatively if you use (Ana)Conda you can also install GDAL binaries through their Conda binary package

0

There's another way to install GDAL, although, the KyngChaos method is a good and easy one and is my recommendation if you don't use a lot of software packages.

Use Homebrew: http://brew.sh/

One Caveat with OSX is that you should only use ONE way of doing each thing. So use only one package manager (so Brew only).

I install GDAL with brew by using:

brew install gdal

and then I can upgrade it by using:

brew upgrade gdal

Using a package manager means that dependencies are handled properly and simply. And it means upgrading in the future is seamless. Brew has a lot of software available, including quite a lot of specialised tools.

You can install QGIS using Brew too, but because of the paradigm, it'll compile it, which will take a very long time, and i don't recommend it!

0

Use Anaconda: https://www.anaconda.com

Open up Terminal: conda install gdal

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.