I am currently reading Python Geospatial Development by Erik Westra but I am stuck at the first hurdle where the book suggests that the easiest way to install gdal onto a windows machine is using FWtools from the website http://fwtools.maptools.org

The first problem is that this is a really old website.

It then says to check if it's successful type >>> import osgeo this is where it fails and I get the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named gdal

The error seems to have come up a number of times on stack exchange:

with the answer being to use OSGEO4W.

The fwtools website hasn't been updated since about 2010 or 2011 and the book is from 2013 second edition so surely they had time to update the installation section, it seems to be a fundamental flaw in the book which has been rated highly on Amazon and by a number of people who know way more about python then I do, So my question is have I missed something really obvious in the book or that is considered general python GIS knowledge? There is nothing in the errata on the books Publishers website Packt Publishing. I don't want to rate the book badly if it something I have missed.


1 Answer 1


FWTools provides supposedly easy-t-use wrappers for a lot of the GDAL functions. Once upon a time FWTools was THE defacto place to go and get your GDAL binaries, but not anymore. Personally I think the Python API for GDAL/OGR is already easy enough for scripting and FWTools is a bit redundant (though it gives some nice convenient utilities in QGIS - so has its place there).

The Binaries at FWTools should still work, so long as you have matched the binaries to your version of Python and MSVC against which they were built. It would be no good using binaries designed to work with Python 2.5 against Python 3.5, or binaraies built against MSVC 10 when you have v8 for instance. In such cases you will probably get the DLL load fail error.

The error you see suggests that you may not have correctly set the GDAL environment variable, and/or the install failed. If you are still having trouble even with a GDAL environment variable set, try also adding "C:/Pythonxx/lib/site_packages" to your PYTHONPATH. You can verify your theoretical install by having a peek in that folder to see if there is a gdal.py module - if not then the install failed.

IMO the book is actually quite good as an intro to Python Geospatial coding (barring the link to FWTools - but in fairness, the book also correctly gives the main website for GDAL and just says windows users might find the FWTools site useful). Have a look here for the official links for the binaries. If you are on Windows then I recommend this link to get the binaries (make sure they match your version of Windows, Python and MSVC. You will need to set a GDAL environment variable to point to the directory GDAL installs to (using the second link, the default is C:\Program Files\GDAL).

EDIT An alternative into to python programming for GDAL is this tutorial. This probably goes into GDAL in a little more depth but the book has a wider scope, covering many other things such as an intro to using SpatiaLite and PostGIS with Python among other things.

  • Thankyou for your reply MappaGnosis, The book describes FWtools as the easiest way to install gdal. Maybe it's because I come from a mapping background and I am trying to learn python and programming but it seems odd that the book doesn't explain how to install it in more detail. I agree that the book does seem good, I skimmed the first 6 chapters and it's interesting but I bought the book to help me learn how to use python but if I have to keep going to other sources/websites then the book becomes redundant.
    – Banger
    Commented Aug 2, 2014 at 1:25
  • Fair points - once you have got GDAL installed (which is admittedly a major hurdle) then you'll find the book helpful. See my edit for a slightly off-topic link which will give you a excellent (if a little old) set of tutorials on GDAL/OGR. They haven't been updated for a while but are still a good intro. Commented Aug 2, 2014 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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