2

I can pip install GDAL for the python2.7 on my mac just fine using pip. However when I try to install the package for my python3.6 using pip3 install gdal I get a long error message that ends with this:

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:3168:10: fatal error: 'cpl_port.h' file not found
    #include "cpl_port.h"
             ^~~~~~~~~~~~
    1 warning and 1 error generated.
    error: command 'clang' failed with exit status 1

I tried re-installing GDAL using homebrew as suggested here, Unable to install GDAL in python 3 using pip (clang failed with exit status 1), but no luck. Looking for any suggestions.

Brad Koch
  • 19,267
  • 19
  • 110
  • 137
J.Hammond
  • 251
  • 3
  • 17
  • Do you currently have GDAL on your system? What version is reported by `ogrinfo --version`? I had a similar problem, my issue was resolved after upgrading gdal to 2.2.4 using homebrew. – Brad Koch Apr 02 '18 at 21:03
  • thanks for getting back on this, I actually never figured it out. I do have GDAL installed its version 2.1.3 – J.Hammond Apr 05 '18 at 17:53

2 Answers2

0

I have tried a lot to install GDAL package using PIP and ended up in either missing some modules or encountered errors. So, best solution for installing GDAL is to setup condo environment and install gdal which will work :

conda create --name yourenvnamehere python=python3.7

conda activate yourenvnamehere

conda install -c anaconda numpy

conda install -c conda-forge gdal

if you have followed the above code:

import gdal

should work. Happy coding with spatial data:)

-1

Anaconda navigator searching the libDo you have anaconda python installed?¿ Inside anaconda navigator you create an environment for python 2.7 or python 3.6, in this case you want 3.6 so create it. And then inside this env you can search for the lib and install it.

if it doesn't work try getting in your terminal (anaconda promp) you get inside your environment doing:

activate Anaconda3_64

(Anaconda3_64 is the name of the environment you defined inside anaconda navigator) and try pip install there.

pip install gdal

it worked for me but i have Windows so hope its the same in mac.

MarcoPolo11
  • 81
  • 1
  • 1
  • 11