GDAL / Install errors

Why GDAL install errors happen and how to fix them

GDAL, rasterio, geopandas and pyproj install and import errors, listed by exact message, each with its cause and fix.

Short answer

The GDAL Python package is only a binding: it must match the C library libgdal and the coordinate database proj.db, and any piece coming from a different installation breaks it.

Setting up your environment this way avoids most errors on this page.

PracticeWhat happens if you skip it
Create a dedicated conda-forge environment and install GDAL, PROJ, rasterio and geopandas in one go.Installing in several rounds from different sources leaves the binding, libgdal and proj.db from different installations, causing DLL load failed and proj.db version errors.
In that environment install geospatial packages only with conda, never topping up with pip.pip brings in a second pyproj or GDAL, and which one loads becomes unpredictable, so errors come and go.
Do not set PROJ_LIB or PROJ_DATA by hand, and keep QGIS and PostGIS folders off PATH.Programs then read the older proj.db and DLLs bundled with that software, causing unrecognized format errors.
On Windows, do not build GDAL from source with pip.Windows has no gdal-config, so the build gets stuck on missing headers.

Troubleshooting by error message

Find your exact error message. Each entry gives the cause, the fix, and what may come up after the fix.

Could not find gdal-config. Make sure you have installed the GDAL native library and development headers. (Also FileNotFoundError: [Errno 2] No such file or directory: 'gdal-config')

Cause: The system has no GDAL library or gdal-config, so pip cannot build the binding from source.

Fix: Install the system GDAL library and headers, then a binding of the same version; it is simpler to install both from conda-forge in a new environment.

What may come next: Whenever either side is upgraded later, the binding and library can drift apart and you get the gdal.h mismatch error below.

While compiling the GDAL binding, the log shows gdal.h errors that do not match the system library

Cause: The binding pip downloaded has a different version from the system libgdal, so the interfaces do not match at build time.

Fix: Pin the binding to the system libgdal version, for example pip install gdal==2.4.2 if the system has 2.4.2.

What may come next: With an old binding pinned, newer rasterio or geopandas may require a newer GDAL and conflict again.

Screenshot of the GDAL binding failing to compile against gdal.h
Source: GDAL GitHub issue #1762. The newer binding source from pip does not match the GDAL 2.4.2 gdal.h on the system, so compilation fails with undeclared identifier.
fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory

Cause: Windows has no gdal-config, so a pip source build cannot find the GDAL headers.

Fix: Do not build from source on Windows; install GDAL from conda-forge or OSGeo4W instead.

What may come next: If QGIS or OSGeo4W is already installed, several sets of GDAL DLLs can interfere and imports fail with DLL load failed.

A GDAL API version must be specified.

Cause: A new Fiona release has no Windows wheel, so pip falls back to a source build that cannot find the GDAL version.

Fix: Pin an earlier Fiona release that has a Windows wheel, or install fiona and geopandas from conda-forge.

What may come next: After downgrading Fiona, a newer geopandas may require a newer Fiona and pip reports a dependency conflict.

ImportError: cannot import name '_gdal_array' from 'osgeo'

Cause: pip reused an old build from its cache, or numpy was not installed when GDAL was built.

Fix: Install numpy first, then rebuild with pip install --no-cache-dir --force-reinstall gdal.

What may come next: The rebuild compiles against the current system library, so a libgdal version mismatch can show up as a new build error.

ModuleNotFoundError: No module named 'osgeo'

Cause: The GDAL binding is installed in a different Python, so the current interpreter cannot find osgeo.

Fix: Run python -c "import sys; print(sys.executable)" to confirm the interpreter, then reinstall GDAL into it.

What may come next: With GDAL installed in both conda and the system Python, the PROJ database can also be read from the wrong place and proj.db errors follow.

ImportError: DLL load failed while importing _gdal

Cause: On Windows the DLLs that _gdal needs cannot be found, or DLLs from another GDAL installation are loaded.

Fix: Reinstall gdal from conda-forge in a clean environment and remove other GDAL folders from PATH.

What may come next: After removing those folders from PATH, QGIS or other tools that rely on that GDAL may stop starting.

ImportError: DLL load failed while importing _version: The specified procedure could not be found.

Cause: The rasterio conda package is mixed with the dynamic libraries bundled with QGIS.

Fix: Install rasterio in a new environment that uses only conda-forge packages, and remove the QGIS folder from PATH.

What may come next: Importing osgeo.gdal before rasterio hides the error for now, but it tends to return on another machine or after an upgrade.

OSError: Could not find lib geos_c.dll or load any of its variants [].

Cause: geos_c.dll exists, but the Microsoft Visual C++ runtime it depends on is missing.

Fix: Install the Microsoft Visual C++ Redistributable for Visual Studio 2022.

Internal Proj Error: proj_create: no database context specified (with UserWarning: pyproj unable to set database path.)

Cause: PROJ cannot find proj.db, usually because an environment variable points to the wrong folder or the packages come from two installations.

Fix: Activate the environment with conda activate so it sets PROJ_DATA itself, and do not set PROJ_LIB or PROJ_DATA system-wide.

What may come next: A PROJ variable set by hand affects every environment, so another environment may then report a proj.db version error.

Screenshot of the pyproj no database context specified error
Source: pyproj GitHub discussion #1262, a PROJ database error reported by a user.
proj_create: unrecognized format / unknown name

Cause: The program read proj.db from another PROJ installation, which lacks the version metadata the current PROJ needs.

Fix: Create a new conda environment, install fiona and pyproj only from conda-forge, and clear PROJ variables you set by hand.

What may come next: If PATH still contains a proj.dll from other software, the new environment may load it too, so clean that up as well.

proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected.

Cause: The program loaded the older proj.db bundled with PostgreSQL or PostGIS.

Fix: Set PROJ_DATA (PROJ_LIB before PROJ 9.1) to the share/proj folder that ships with pyproj.

What may come next: After this change, PostGIS and other programs that expect the older proj.db may start failing instead.

rasterio.errors.CRSError: The EPSG code is unknown. PROJ: proj_create_from_database: Cannot find proj.db

Cause: rasterio before 1.2.0 cannot find the PROJ database, or an environment variable points to an older PROJ.

Fix: Upgrade to rasterio 1.2.0 or later and remove any PROJ_LIB or PROJ_DATA variable that points to an older PROJ.

What may come next: Upgrading rasterio also upgrades the GDAL it depends on, which conflicts with environments that pin a GDAL version.

pyproj unable to set database path. (geopandas and pyproj come from conda and pip)

Cause: conda and pip each installed pyproj, so the data folder and the library the program loads do not match.

Fix: Remove pyproj and geopandas from both, then install them together from conda-forge in a new conda environment.

What may come next: Installing another geospatial package with pip later can bring in a second pyproj again and the problem returns.

Scientify is a cloud computer with research software installed and AI agents such as Codex and Claude Code built in. Describe what you need in one sentence, for example "clip these satellite images to the study area, reproject them to EPSG:4326 and compute NDVI", and the agent uses the preinstalled GDAL to do the modeling and computation, with no software to install and no code to write.

Compared with installing more on your own computer, the cloud computer already has GDAL 3.13.3, PROJ 9.9.0, rasterio 1.5.2 and geopandas 1.2.0 matched and ready, and runs continue after you close your laptop.

The cloud computer comes with more computing power: CPU and GPU clusters can be called on demand for large-scale scientific computing. Compute is billed by the minutes you actually use, so nothing is wasted.

Cloud computer
4 vCPU · 8 GB
Top configuration, for data processing and small to medium jobs
Callable GPU
96 GB VRAM
Up to an RTX PRO 6000 per GPU; H800 80 GB and up to 8 × A10G also available
Callable CPU
224 cores · 3 TB
Largest spec, for large parallel computations

References

Frequently asked questions

Should I install GDAL with pip or conda?

Prefer conda-forge. pip GDAL has no prebuilt wheel and needs a matching system GDAL library first; conda-forge installs GDAL, PROJ and the binding together.

Can GDAL be installed on Windows?

Yes, but do not build it from source with pip. Use conda-forge or OSGeo4W, and avoid several GDAL installations on PATH.

Why does it say proj.db cannot be found?

There are usually several PROJ installations and the program reads the wrong database. Install in an environment that uses only conda-forge and remove PROJ variables you set by hand.

Compute with GDAL without setting up an environment

Upload your data, describe the computation, and Scientify runs it on a cloud computer that is already set up. New accounts get a free cloud computer and US$5 in credit.