I tried to install GDAL in macos by the command for django brew install gdal and it successfully installed and I have also used pip install GDAL command and it also installed successfully.

But, When I tried to run the django server it throw a error set a path for GDAL library.

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.


1 Answer 1


I also encountered this error recently on macOS 12.0.1 Monterey (full context at the end of this answer) after installing PostGIS via brew:

brew install postgis

The solution was to manually set GDAL_LIBRARY_PATH (link) and GEOS_LIBRARY_PATH (link) in settings.py:

GDAL_LIBRARY_PATH = '/opt/homebrew/opt/gdal/lib/libgdal.dylib'
GEOS_LIBRARY_PATH = '/opt/homebrew/opt/geos/lib/libgeos_c.dylib'

There was a GEOS-related error after fixing the GDAL one, so I needed both settings.

Finding the library files

The locations of those files may differ depending on your setup, but can be found using:

find /opt -name "libgdal.dylib" -print 2>/dev/null
find /opt -name "libgeos_c.dylib" -print 2>/dev/null

Each search may return multiple results. It's usually a list of symbolic links (that ultimately point to the same file), so pick the file path which doesn't have a package version in it (since that may change with a brew update).

Original context

I recently migrated from an Intel Mac (macOS 11.6 Big Sur/Homebrew 3.2.15) to an Apple Silicon Mac (macOS 12.0.1 Monterey/Homebrew 3.3.4). I didn't have to use the above settings in my previous setup despite installing PostGIS in exactly the same way. Everything else stayed the same (Python 3.9 / Django 3.2.9 / PostGIS 3.1.4 etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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