Skip to content

Instantly share code, notes, and snippets.

@mobilestack
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mobilestack/8749261 to your computer and use it in GitHub Desktop.
Save mobilestack/8749261 to your computer and use it in GitHub Desktop.
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

or

from django.contrib.gis import gdal

both give the error result as in:

http://stackoverflow.com/questions/21487831/when-configuring-geodjango-gdal1-10-and-python3-3-are-incompatible-on-windows7/21495318#21495318

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

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

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: http://vbkto.dyndns.org/sdk/. 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 settings.py,

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