ArcGIS, GDAL/OGR, General, Python, Tutorial

Installing GDAL / OGR for Python on Windows

Installing GDAL/OGR for Python on Windows is now even easier!

Christoph Gohlke, through his Unofficial Windows Binaries for Python Extension Packages, provides a number of libraries as Python Wheel files, which you can easily install to your desired Python… Unlike some other installers this installer includes GDAL, its data and the Python bindings all in the one installer.

Overview

1. Determine your desired Python install and version
2. Download the GDAL installer/bindings
3. Install
4. Notes

1. Determine your desired Python install and version

See the post on Locating Python and adding it to your system Path for information about how to find the Python install you wish to use (you do not need to add it to your system Path to continue with the steps below).

Once you have figured out which Python you are going to use, open the Python interpreter in your normal way (or double click on its python.exe). It will print version information at the top when it opens, for example: Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32

The important information is highlighted above: my version is Python 2.7 (the additional .10 is not important) and its architecture is 32 bit.

2. Download the GDAL installer/bindings

Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal and select the appropriate download corresponding to your Python version. Unless you specifically need an older version you might as well download the latest GDAL version. The filename has the format:

  GDAL-[GDAL version]-cp[python version]-none-[architecture].whl

So, based on the example above, I would download:

  GDAL-2.0.2-cp27-none-win32.whl

3. Install

Wheel files are installed usingĀ pip, a package manager for Python that is included in the default install. The syntax is (if pip is on your system path):

  pip install GDAL-[etc.].whl

Otherwise:

  [path to your desired python]\Scripts\pip install GDAL-[etc.].whl

4. Notes

Test your install by opening Python and entering:

  import ogr

This should return nothing (meaning no errors).

Advertisements

5 thoughts on “Installing GDAL / OGR for Python on Windows

  1. If you use the ‘Gohlke approach’, you might face problems with the command-line use of GDAL/OGR – because the Gohlke whl puts all of the GDAL/OGR stuff under [PYTHONPATH]\Lib\site-packages\osgeo

    So you’ll need to ensure that your environment variables match that (easiest way: search for , and you’ll also need to move ogr_FileGDB.dll from [PYTHONPATH]\Lib\site-packages\osgeo\plugins to [PYTHONPATH]\Lib\site-packages\osgeo – without changing the GDAL_DRIVER_PATH if it’s set.

  2. Great work!
    Some adjusments might be needed in Windows registry. In my case it was creating some conflict with the invasive ArcGIS python installation (including the DLL load Failed: %1 … error) when executing scripts from DOS shell. After some google search I found this very useful code repo:
    https://github.com/maphew/code/tree/master/register-python.
    Also look at the last entry here about creating registry keys in Windows 7 x64:
    http://nedbatchelder.com/blog/200810/switching_python_versions_on_windows.html
    Cheers!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s