Skip to content

Instantly share code, notes, and snippets.

@Rodrigo-NH
Last active October 5, 2023 12:36
Show Gist options
  • Save Rodrigo-NH/94d1fe07646052ad32133824c85b4221 to your computer and use it in GitHub Desktop.
Save Rodrigo-NH/94d1fe07646052ad32133824c85b4221 to your computer and use it in GitHub Desktop.
Install GDAL and GDAL python Bindings in Windows with OSGeo4W
1.
Get OSGeo4W https://trac.osgeo.org/osgeo4w/
2.
Run OSGeo4W and install packages and auto selected dependencies:
gdal
python3-gdal
proj
proj-data
3.
Take note of python3-core version to be installed in OSGeo4W 'Resolve Dependencies' screen. This is the python version gdal was compiled against
4.
Download and Install regular python for windows (if not yet). Must be same python version gdal was compiled against. "Install for all users" and "Add Python to environment variables" suggested
All commands in command line (cmd.exe) with administrator rights. If unsure, set the paths manually. Adjust accordingly your case
4. Insert "C:\OSGeo4W\bin" to PATH System Variable (Environment Variables)
5. Restart cmd.exe session
6. Check gdal is installed
gdalinfo --version
7. Use version above to set system variable:
setx /m GDAL_VERSION 3.7.2
8. Set GDAL paths
setx /m GDAL_DRIVER_PATH "C:\OSGeo4W\apps\gdal\lib\gdalplugins"
setx /m GDAL_DATA "C:\OSGeo4W\apps\gdal\share\gdal"
setx /m PROJ_LIB "C:\OSGeo4W\share\proj"
9. Set symlink for python bindings e.g.
mklink /D "C:\Program Files\Python39\Lib\site-packages\osgeo" "C:\OSGeo4W\apps\Python39\Lib\site-packages\osgeo"
If you want gdal bindings working inside virtual environments just repeat the mlink command above pointing to venv directory (e.g. ...venv\Lib\site-packages\osgeo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment