1

I'm trying to pip install gdal and struggling. Have spent hours trawling through SO, Github and other posts to try and resolve this one but nothing I've tried works. I've tried:

  • xcode-select --install
  • brew doctor maintenance
  • adding to .bash_profile, e.g

    • export CPATH=/Library/Developer/CommandLineTools/usr/include/c++/v1
    • export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
    • export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/

And various other things. I cannot escape this error.

$ pip install gdal

... [4,382 lines] ...

    /usr/local/include/pthread.h:540:6: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
    /usr/local/include/pthread.h:200:34: note: expanded from macro '_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT'
            defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1))
                                            ^
    extensions/gdal_wrap.cpp:3096:10: fatal error: 'stdexcept' file not found
    #include <stdexcept>
             ^~~~~~~~~~~
    195 warnings and 1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/username/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/_3/b8whcf8d1bb8w_lr2rrscb5m0000gp/T/pip-install-utjkt9xt/gdal/setup.py'"'"'; __file__='"'"'/private/var/folders/_3/b8whcf8d1bb8w_lr2rrscb5m0000gp/T/pip-install-utjkt9xt/gdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/_3/b8whcf8d1bb8w_lr2rrscb5m0000gp/T/pip-record-u1hcib4k/install-record.txt --single-version-externally-managed --compile --install-headers /Users/username/anaconda3/include/python3.7m/gdal Check the logs for full command output.

Full error log at https://gist.github.com/geotheory/44e66c17e61c80398ab56590c5634703

Has anyone with macOS Cataloina also running Anaconda and Homebrew got past this?

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240
geotheory
  • 22,624
  • 29
  • 119
  • 196
  • 1
    If you are using anaconda, the easiest way to get gdal is to use `conda install gdal`. – cel Apr 24 '20 at 12:10
  • It's looking for `C++` headers in `/usr/local/include`, which doesn't exist in Catalina. – l'L'l Apr 24 '20 at 12:10
  • Thanks. I think this diagnosis leads to [this symlink solution](https://stackoverflow.com/a/58349403/1156245) which I've already tried. – geotheory Apr 24 '20 at 13:15
  • @cel Ah that works! Thanks. But the underlying C++ cause is presumably not resolved. I'm still keen to crack that as other lib compile jobs have failed recently. – geotheory Apr 24 '20 at 13:23
  • As an aside, it seems that you can get GDAL from conda-forge (https://anaconda.org/conda-forge/gdal). – AMC Apr 26 '20 at 22:58

0 Answers0