0

Django 4.1.5 on M1 Ventura 13.3.1 (22E261) failing to detect GDAL installation even when enumerated per the documentation. Is this a version error or a pointer error? I don't really understand what could cause this. According to the django docs, this newer version of GDAL is not compatible with Django. Would that cause it to fail to be detected?

Error Message

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

Environment Settings:

interpreter python 3.11 in a pipenv:

/Users/<username>/Documents/GitHub/optiagbe/venv/bin/python

gdal 3.6.4 installed via homebrew at:

/Users/<username>/homebrew/Cellar/gdal/3.6.4/lib/libgdal.32.3.6.4.dylib

gdal virtual pointer located at

/Users/<username>/homebrew/lib/libgdal.dylib appears to properly point to the above installation

Django Project Configuration:

settings.py

GDAL_LIBRARY_PATH = '/Users/<username>/homebrew/lib/libgdal.dylib'

GEOS_LIBRARY_PATH = '/Users/<username>/homebrew/Cellar/geos/3.11.1/lib/libgeos_c.dylib

1 Answer 1

0

This appeared to be the result of some forced homebrew update that occured when I installed another package earlier today. Steps to resolve:

  1. Uninstall postgis: brew uninstall postgis
  2. Uninstall GDAL: brew uninstall --force gdal
  3. Unisntall poppler: brew uninstall poppler
  4. Cleanup: brew cleanup

Reinstallation:

  1. Install new postgis brew install postgis (This should install the dependent GDAL lib and poppler).

Relist paths in Djagngo settings.py

GDAL_LIBRARY_PATH = '/Users/<username>/homebrew/Cellar/gdal/3.6.4/lib/libgdal.dylib' GEOS_LIBRARY_PATH = '/Users/<username>/homebrew/Cellar/geos/3.11.2/lib/libgeos_c.dylib'

Cause

My build was previously stable with this config:

GDAL_LIBRARY_PATH = '/Users/<username>/homebrew/Cellar/gdal/HEAD-3493a0f/lib/libgdal.32.3.7.0.dylib'

GEOS_LIBRARY_PATH = '/Users/<username>/homebrew/Cellar/geos/3.11.1/lib/libgeos_c.dylib'

Looks like the auto-update from 3.11.1 to 3.11.2 that homebrew ran caused the file path in django settings to become invalidated. Typically you can get the version-agnostic path of a brew lib at /Users/<username>/homebrew/lib/libabsl_flags.dylib such that when the package is updated, it doesn't break django. For some reason the GDAL installation did not place the shortcut in this folder so it will break again when it updates. Similar to this issue

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.