title: Django: Could not find the GDAL library (OSX)
body: <p>After my old macbook died I am transferring across a Django Webapp I'd been building to my new machine (which is a MacBook Pro M1 2021). I am currently in the process of reinstalling the correct packages and extensions for the app.</p>
  <p>However I am currently getting the following error when I do <code>python3 manage.py runserver</code>:</p>
  <pre><code>django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library 
  (tried &quot;gdal&quot;, &quot;GDAL&quot;, &quot;gdal3.3.0&quot;, &quot;gdal3.2.0&quot;, &quot;gdal3.1.0&quot;, 
  &quot;gdal3.0.0&quot;, &quot;gdal2.4.0&quot;, &quot;gdal2.3.0&quot;, &quot;gdal2.2.0&quot;, &quot;gdal2.1.0&quot;, &quot;gdal2.0.0&quot;). 
  Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
  </code></pre>
  <p>The database I created was through a server on Postgres.app which I believe comes <a href="https://postgis.net/install/" rel="noreferrer">packaged up with PostGIS, GDAL etc.</a></p>
  <p>I have also run <code>pip3 install GDAL</code> and <code>brew install GDAL</code></p>
  <p>I have tried following the <a href="https://docs.djangoproject.com/en/4.0/ref/contrib/gis/install/#postgres-app" rel="noreferrer">geoDjango documentation</a> and I added the following in the terminal:</p>
  <pre><code>export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/14/bin
  </code></pre>
  <p>When I run <code>which psql</code> it returns: <code>/Applications/Postgres.app/Contents/Versions/14/bin/psql</code></p>
  <p>I can't figure it out.</p>
  <p>Full traceback of error:</p>
  <pre><code>Watching for file changes with StatReloader
  Exception in thread django-main-thread:
  Traceback (most recent call last):
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py&quot;, line 973, in _bootstrap_inner
      self.run()
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py&quot;, line 910, in run
      self._target(*self._args, **self._kwargs)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/utils/autoreload.py&quot;, line 64, in wrapper
      fn(*args, **kwargs)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/core/management/commands/runserver.py&quot;, line 115, in inner_run
      autoreload.raise_last_exception()
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/utils/autoreload.py&quot;, line 87, in raise_last_exception
      raise _exception[1]
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/core/management/__init__.py&quot;, line 381, in execute
      autoreload.check_errors(django.setup)()
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/utils/autoreload.py&quot;, line 64, in wrapper
      fn(*args, **kwargs)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/__init__.py&quot;, line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/apps/registry.py&quot;, line 114, in populate
      app_config.import_models()
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/apps/config.py&quot;, line 300, in import_models
      self.models_module = import_module(models_module_name)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1030, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1007, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 986, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 680, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 850, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 228, in _call_with_frames_removed
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/auth/models.py&quot;, line 3, in &lt;module&gt;
      from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/auth/base_user.py&quot;, line 47, in &lt;module&gt;
      class AbstractBaseUser(models.Model):
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/models/base.py&quot;, line 122, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/models/base.py&quot;, line 326, in add_to_class
      value.contribute_to_class(cls, name)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/models/options.py&quot;, line 207, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/utils/connection.py&quot;, line 15, in __getattr__
      return getattr(self._connections[self._alias], item)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/utils/connection.py&quot;, line 62, in __getitem__
      conn = self.create_connection(alias)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/utils.py&quot;, line 204, in create_connection
      backend = load_backend(db['ENGINE'])
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/db/utils.py&quot;, line 111, in load_backend
      return import_module('%s.base' % backend_name)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/db/backends/postgis/base.py&quot;, line 6, in &lt;module&gt;
      from .features import DatabaseFeatures
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/db/backends/postgis/features.py&quot;, line 1, in &lt;module&gt;
      from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/db/backends/base/features.py&quot;, line 3, in &lt;module&gt;
      from django.contrib.gis.db import models
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/db/models/__init__.py&quot;, line 3, in &lt;module&gt;
      import django.contrib.gis.db.models.functions  # NOQA
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/db/models/functions.py&quot;, line 3, in &lt;module&gt;
      from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/db/models/fields.py&quot;, line 3, in &lt;module&gt;
      from django.contrib.gis import forms, gdal
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/forms/__init__.py&quot;, line 3, in &lt;module&gt;
      from .fields import (  # NOQA
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/forms/fields.py&quot;, line 2, in &lt;module&gt;
      from django.contrib.gis.gdal import GDALException
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/__init__.py&quot;, line 28, in &lt;module&gt;
      from django.contrib.gis.gdal.datasource import DataSource
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/datasource.py&quot;, line 40, in &lt;module&gt;
      from django.contrib.gis.gdal.driver import Driver
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/driver.py&quot;, line 5, in &lt;module&gt;
      from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/prototypes/ds.py&quot;, line 9, in &lt;module&gt;
      from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
    File &quot;/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/contrib/gis/gdal/libgdal.py&quot;, line 46, in &lt;module&gt;
      raise ImproperlyConfigured(
  django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried &quot;gdal&quot;, &quot;GDAL&quot;, &quot;gdal3.3.0&quot;, &quot;gdal3.2.0&quot;, &quot;gdal3.1.0&quot;, &quot;gdal3.0.0&quot;, &quot;gdal2.4.0&quot;, &quot;gdal2.3.0&quot;, &quot;gdal2.2.0&quot;, &quot;gdal2.1.0&quot;, &quot;gdal2.0.0&quot;). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
  </code></pre>