Installing GDAL with Python on windows?

  • Can anyone explain 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.

    Can someone describe the process, including links to the files/folders I will need?

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


  • scw

    scw Correct answer

    10 years ago

    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.

    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

    also, I am not sure where it installed gdal? any thoughts?

    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.

    yeah... so I ran OSGEO command line and ran python, still could not import gdal. I return to my original question

    Try `from osgeo import gdal`

    This is what I get:

    H:\>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from osgeo import gdal >>> dir(gdal) ['AllRegister', 'AutoCreateWarpedVRT', 'Band', 'Band_swigregister', 'CE_Debug', 'CE_Failure', 'CE_Fatal', 'CE_None', 'CE_Warning',

    Hey Guido, there should be a bunch of .py files in OSGeo4/apps/gdal-16/pymod Shouldn't this be a new question?

    @scw please consider rolling up the examples from the comments into your answer. It will make it easier to piece the relevant information together into a cohesive whole (in part because of being able to preserve code formatting). Vote up the comments you use as means of crediting and acknowledging the source.

    Just note that OSGeo4W does not yet support GDAL 1.7, sticking to version 1.6 last time I checked.

    ... 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)

    Is there a way to use "from osgeo import gdal" from my main python shell instead of using OSGEO's shell?

    @AlexisEggermont it is possible, but mixing multiple Python environments together is fraught with challenges. Probably a better approach is to use something like Miniconda to create a single Python environment which contains GDAL and the rest of the packages you're used to having.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM