Installing GDAL with Python on windows?

Unless you have good reasons not to, I'd definitely recommend starting with the OSGeo4W installer, which can install multiple different versions of GDAL and their relevant Python bindings. It works great and dramatically simplifies the Windows deployment story. Specifically, you'll want to install pkg-gdal-python, which is within 'Libs' in the installer tree.


You can download GDAL wheel package from Christoph Gohlke's Unofficial Windows Binaries for Python Extension Packages.

It can be installed from cmd.exe using something like:

c:\Python27\Scripts\pip.exe install GDAL-X.Y.Z-cp27-none-win_XYZ.whl

(You should install NumPy from the same place using a similar command)

While the package is not built by OSGeo or GDAL developers, it is a high quality distribution with support for the latest versions of GDAL compiled for 32-bit and 64-bit versions of Python. No external libraries need to be added or managed!

Update it even sets the GDAL_DATA environment variable, if it is not set, and includes a PostgreSQL driver to read data from PostGIS.


Another option is to install the Anaconda Python distribution which has packages for GDAL. If you are going to be doing a lot of work using GDAL with other Python packages (scipy, pandas, scikit-learn etc.,) this might be a better option than OSGeo4W. On the other hand if you want to use Python in combination with a number of open source remote sensing and GIS packages (GRASS, QGIS etc.,) OSGeo4W is probably the better option.

You can get the full Anaconda distribution from: https://www.continuum.io/downloads which contains a lot of Python packages aimed at 'data science' or a minimal installation from http://conda.pydata.org/miniconda.html

As part of the installation it will prompt you to add to the main path (so it is available from any terminal).

Once set up GDAL can be installed into a new environment using:

conda create -n gdal_env -c conda-forge gdal

Then activating it as show when the command finishes. Installing into a new environment is recommended to avoid conflicts with other packages and make sure the environmental variables required are set.

I've suggested installing from the conda-forge channel (https://conda-forge.github.io/) as they are very active in keeping their GDAL builds up to date and making sure they work against a lot of libraries.

Once installed packages can be updated from within the environment using:

conda update gdal