Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Can anyone please explain to me in step by step instructions how to install GDAL/OGR with Python on Windows. I have Windows Vista and I have tried following the information on the website and it does not seem to bind the exe files for me.

So, if someone would be so kind to walk me through the process, including links to the files/folders I will need I would be happy to do a screen cast to continue to share this with the rest of the world.

thanks in advance

--20100930 update-- I have now tried to run the gdal setup with minGW, but this has also failed:

GDAL_FAIL

share|improve this question

10 Answers 10

up vote 28 down vote accepted

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.

share|improve this answer
    
+1 OSGeo4W is really great once you get used to it. –  underdark Sep 29 '10 at 19:24
1  
So I used the OSGeo4W installer to install gdal and then tried their little command line interface, but was still unable in python to do the following: import gdal –  GuidoS Sep 30 '10 at 16:21
2  
OSGEO4W installs it's own Python instance under the OSGEO4W root. To use the Python that includes gdal and all of the other OSGEO modules, open the OSGEO4W shell start>program files>osgeo4w. Launch Python or run a Python script from there. –  DavidF Sep 30 '10 at 16:51
4  
Try from osgeo import gdal –  DavidF Sep 30 '10 at 19:41
2  
... skip to March 2011 ... OSGeo4W now has the default GDAL distribution at version 1.8 (versions 1.5, 1.6 and 1.7 are optional) –  Mike T Mar 23 '11 at 10:58

I know The OSGEO installer was mentioned, but as GuidoS said it doesn't work unless you're on the osgeow shell, which is fine and dandy if all you're doing is basic python. Chances are if you're not, you either have to reinstall the package and then have to run your app/plugin from that folder or have to compile all the dependencies for gdal and install it again.

What works for me is:

  • In PyDev/Eclipse (not my primary IDE), I add the list of libraries to the default python interpreter
  • Use the built in console to run the files
share|improve this answer
3  
You can set o4w python as the system default python, e.g. make it available to everything, by adding it to the system registry. There is a python script for doing this on 32bit windows at trac.osgeo.org/osgeo4w/ticket/114 (64bit must be added by hand). –  matt wilkie Oct 12 '10 at 17:31

I use FWTools in Windows XP. It includes a Python installation with the GDAL libraries. After installation, just run your Python scripts from the FWTools Shell.

share|improve this answer

Its really not that difficult to do. I've compiled it many times before using Visual Studio without any issues. Just follow the directions here: link text.

It's pretty straightforward, just read through the well documented makefile.vc and set the appropriate directories, notably the Python one. Once it's built you should have a Python module built which you can then copy to your Python installation, which I've always done maually, but there is probably a more approriate method.

share|improve this answer
    
I will try this out over the weekend... thanks –  GuidoS Oct 15 '10 at 21:05

Another current, very easy option for downloading the gdal binaries is at Christoph Gohlke’s site

Thanks to blog post at http://fuzzytolerance.info/code/postgis-raster-ftw/ for the link.

share|improve this answer

Like the other contributors, I advice to choose OSGEO4W installer.

If for any reasons, you don't want or can't use it, see the Python packages documentation on gdal http://pypi.python.org/pypi/GDAL/

You will discover, for example, there are gdal binaries on OSGEO website

share|improve this answer

Install native GDAL on Windows for 32/64-bit versions, currently Python 2.6 to Python 3.3: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal

So far, I'm impressed with the quality of this Python distribution for Windows. Not only is it a recent version of GDAL (presently 1.9.2), but no external libraries need to be added or managed. (It includes gdal19.dll, etc. and the GDAL_DATA directory). You can use PythonWin or whatever else you install on your system.


Two drawbacks that I have noticed with this particular package:

  1. It does not support the PostgreSQL driver for PostGIS. If you don't need it, then this isn't a problem.
  2. It includes the GDAL data directory, but it does not set the GDAL_DATA environment variable to it. Perhaps you have this variable set by another installation (e.g., the Windows PostGIS installer does this), which is OK. But if GDAL_DATA is not set, there could be some issues with the OGR module.

Here is a workaround to get GDAL_DATA working with the package if it is broken. Find the top-level package Python source file, e.g. C:\Python27\Lib\site-packages\osgeo\__init__.py and add:

# __init__ for osgeo package.
import os
if 'GDAL_DATA' not in os.environ:
    os.environ['GDAL_DATA'] = os.path.join(os.path.dirname(__file__), 'data', 'gdal')
share|improve this answer
    
+1 I've found that page an invaluable source of Python distributions for 64-bit Windows –  geographika May 17 '11 at 19:46
1  
I'm having difficulty with this installer working as it is failing to detect my python installations. I have python26 and python27 installed in C:/Python2X but it can't find it.... nevermind! Choose 64 bit instead of 32.... –  djq Dec 27 '11 at 15:11
    
This worked for me much easier than the accepted answer since I don't want another install of Python and Numpy. –  Ahmed Fasih Jan 14 at 20:28

I just did it yesterday following this tutorial http://www.gis.usu.edu/~chrisg/python/2009/docs/gdal_win.pdf It worked fine to me.

share|improve this answer

Here is another tutorial which explains very simple and easy way of installing GDAL v1.8 with Python v2.7 on a Windows XP/7 system.

http://cartometric.com/blog/2011/10/17/install-gdal-on-windows/

share|improve this answer

I had much problem today, but now it is solved, and I put my recordings here,

https://gist.github.com/mobilestack/8749261

basically, I refer to the accepted answer of this question

http://stackoverflow.com/questions/6009506/unable-to-install-python-and-gdal-dll-load-failed

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.