Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install Gdal for Postgis on Windows7, x64, Python3.3

I am developing a Django site and my development machine uses Windows7, X64, since Postgis is more or less the best option, I decided to migrate my database from sqlite3 to Postgresql, and on production side, migrating Mysql to Postgresql.

So on development side, I install the Postgresql from a binary installer, which includes an optional Postgis extension for intallation. Although it says Gdal is included, but my Python3.3 just cannot find it. If I test it in Python:

from osgeo import gdal


from django.contrib.gis import gdal

both give the error result as in:

Then I installed OSGeo4W, and it does not work as well. Finally, I find this answer

and this one works at last. What I did is to find a

Install python of your choosing, I used v2.7.2 x64 downloaded from the official website

Run python from command line to determine the compiler version used to build python (mine shows this message: Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32)

Download the corresponding SDK from this link: Select the GDAL and MapServer latest release >versions packages (if using the above configuration, then MSVC2008 (Win64) -release link should be selected).

From the subpage, download the following:

GDAL core components and Python bindings

Install GDAL core components, add the installation dir to path, and add new environment variable 'GDAL_DATA' pointing to >data subdirectory of GDAL installation.

Install python bindings

I spent two days to configure this problem. And it is not ended yet. The next one is Geos and Proj, both of which should be there before Postgis can be used.

And Goes now, just add this line to,

GEOS_LIBRARY_PATH = 'C:/Program Files/GDAL/geos_c.dll'

then it is fine to use postgis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment