[Django]-How do I solve "django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library" when running PyCharm test?

22πŸ‘

βœ…

On Mac High Sierra, I ran

brew install gdal

and this fixed the issue.

πŸ‘€Dave

46πŸ‘

In Ubuntu you can install GDAL library by running:

sudo apt-get install gdal-bin

This fixed the error.

πŸ‘€iraj jelodari

1πŸ‘

For Mac OS

Run brew install gdal
If you already have it installed, and are still facing the issue, I did the following.

Run

brew info gdal geos

This will list the current path where they are installed and their dependencies. Something like this,

==> gdal: stable 3.7.2 (bottled), HEAD
Geospatial Data Abstraction Library
https://www.gdal.org/
Conflicts with:
  avce00 (because both install a cpl_conv.h header)
  cpl (because both install cpl_error.h)
/opt/homebrew/Cellar/gdal/3.7.2 (474 files, 27.9MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-09-25 at 13:35:19
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/gdal.rb
License: MIT
==> Dependencies
Build: boost βœ”, cmake βœ”, pkg-config ✘, swig ✘
Required: apache-arrow βœ”, cfitsio βœ”, epsilon βœ”, expat βœ”, freexl βœ”, geos βœ”, giflib βœ”, hdf5 βœ”, jpeg-turbo βœ”, jpeg-xl βœ”, json-c βœ”, libarchive βœ”, libgeotiff βœ”, libheif βœ”, libkml βœ”, liblerc βœ”, libpng βœ”, libpq βœ”, libspatialite βœ”, libtiff βœ”, libxml2 βœ”, netcdf βœ”, numpy ✘, openexr βœ”, openjpeg βœ”, openssl@3 ✘, pcre2 βœ”, poppler βœ”, proj βœ”, python@3.11 βœ”, qhull βœ”, sqlite βœ”, unixodbc βœ”, webp ✘, xerces-c βœ”, xz βœ”, zstd βœ”
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 14,204 (30 days), 33,238 (90 days), 65,053 (365 days)
install-on-request: 11,665 (30 days), 27,230 (90 days), 53,906 (365 days)
build-error: 90 (30 days)

==> geos: stable 3.12.0 (bottled)
Geometry Engine
https://libgeos.org/
/opt/homebrew/Cellar/geos/3.12.0 (491 files, 13.7MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-08-23 at 12:46:05
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/geos.rb
License: LGPL-2.1-or-later
==> Dependencies
Build: cmake βœ”
==> Analytics
install: 4,065 (30 days), 14,532 (90 days), 31,010 (365 days)
install-on-request: 1,753 (30 days), 6,409 (90 days), 13,380 (365 days)
build-error: 0 (30 days)

For all the packages marked x, run brew install individually.

After that add
GDAL_LIBRARY_PATH = '/opt/homebrew/Cellar/gdal/3.7.2/lib/libgdal.dylib' GEOS_LIBRARY_PATH = '/opt/homebrew/Cellar/geos/3.12.0/lib/libgeos_c.dylib'

to your settings.py (Exact path may differ with version)

πŸ‘€Sandeep Singh

-1πŸ‘

in poetry:

poetry shell

sudo apt-get install gdal-bin

πŸ‘€c2kTec

Leave a comment