Skip to content

Instantly share code, notes, and snippets.

@danabauer
Forked from whalesalad/gdal-on-osx.md
Created May 4, 2017 07:36
Show Gist options
  • Save danabauer/a3afc521971eefb3e6aa29e1d799b928 to your computer and use it in GitHub Desktop.
Save danabauer/a3afc521971eefb3e6aa29e1d799b928 to your computer and use it in GitHub Desktop.

GDAL on OS X

This will resolve issues with GDAL on OS X in your virtualenv:

  • brew install gdal
  • From OUTSIDE a virtualenv (try, deactivate), run this command to find your system site-packages directory: python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
    • Chances are this will be /Library/Python/2.7/site-packages
    • Note: this is where pip install ... packages are placed
  • Copy the gdal-XXX.pth file to the site-packages directory of your virtual environment.
  • Find your site packages directory for your virtual env by running the earlier command, python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())", from inside an activated virtualenv.

Example, I use ~/Envs as my WORKON_HOME (where virtualenv creates environments), so my command would be:

cp /Library/Python/2.7/site-packages/gdal-py2.7.pth ~/Envs/rex/lib/python2.7/site-packages/gdal.pth

Now GDAL will work inside Python.

In production deployments this dependency is handled entirely inside of the Dockerfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment