Unable to install GDAL in python 3 using pip (clang failed with exit status 1)

After running sudo pip3.4 install gdal from terminal (Mac OS X Mavericks) I obtain an error message saying that the 'col_port.h' file was not found and displaying the following error: command '/user/bin/clang/ failed with exit status 1 (the full message is below).

I have gdal 1.11 (the complete framework version downloaded from kingchaos.com) and the most recent version of the Xcode command line tools -Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)


Here is the error that I get after running the sudo pip3.4 install gdal command:

/usr/bin/clang -fno-strict-aliasing -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -I/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.11/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.6-intel-3.4/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:2230:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
extensions/gdal_wrap.cpp:2233:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
extensions/gdal_wrap.cpp:2535:22: warning: unused variable 'swig_empty_runtime_method_table' [-Wunused-variable]
  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
                     ^
extensions/gdal_wrap.cpp:2855:10: fatal error: 'cpl_port.h' file not found
#include "cpl_port.h"
         ^

3 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

Upvotes: 7

Views: 3830

Answers (2)

PdevG
PdevG

Reputation: 3677

Had this problem today. Installed GDAL with brew and it failed with pip3. The solution was to make sure that the version you try to install with pip is the same as homebrew has installed.

So first install gdal with homebrew using

brew install gdal

You should be able to see the version that is being installed during installation. If you have already installed gdal before you can check the version with:

brew info gdal

For me this showed that the version of gdal brew installed for me was: 2.4.4 So then you can install the correct version with pip using

pip3 install gdal==2.4.4

This finally worked for me.

Upvotes: 1

The solution was to use homebrew and, after that, run pip3.4

brew install GDAL

and, once installed,

pip3.4 install gdal

Upvotes: 4

Related Questions