views:

43

answers:

2

I'm building my first GeoDjango project but I'm kinda desperate.

I'v installed PostgreSQL 9 and PostGis 1.5 through one-click installer on Windows. So everthing is there. I set GEOS_LIBRARY_PATH to the full path of libgeos_c-1.dll in settings.py. But when I run manage.py syncdb, I encounter the following errors:

  File "C:\Python25\lib\site-packages\django\contrib\gis\geometry\backend\geos.py", line 1, in <module>
    from django.contrib.gis.geos import \
  File "C:\Python25\Lib\site-packages\django\contrib\gis\geos\__init__.py", line 6, in <module>
    from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex
  File "C:\Python25\Lib\site-packages\django\contrib\gis\geos\geometry.py", line 14, in <module>
    from django.contrib.gis.geos.coordseq import GEOSCoordSeq
  File "C:\Python25\Lib\site-packages\django\contrib\gis\geos\coordseq.py", line 9, in <module>
    from django.contrib.gis.geos.libgeos import CS_PTR
  File "C:\Python25\lib\site-packages\django\contrib\gis\geos\libgeos.py", line 51, in <module>
    lgeos = CDLL(lib_path)
  File "C:\Python25\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

So I open libgeos.py and check the line specified. It's just a simple "CDLL(lib_path)". Apparently lib_path is GEOS_LIBRARY_PATH.

So I create a simple test:

from ctypes import CDLL

lgeos = CDLL('libgeo's path')

Still have the same problem. So it's simply not able to use CDLL to load this dll at all with python. At this stage, I don't know what to do. Please help.

+1  A: 

Different things come to my mind, the most obvious being: You did paste the path to the DLL file in there, not just the folder it resides in? No offense meant, just to be on the safe side.

Then, you might also get this error if there are unresolved dependencies, i.e. the DLL's LoadLibrary fails because it is missing another library it depends on. You can easily find that out using Dependency Walker. Load libgeos with depends and look for missing modules, error messages etc. - you might be missing libgeos-X-Y-Z.dll, for example.

Jim Brissom
I pasted the full path, that's folder + file name. I just used Dependecy Walker to check LIBGEOS_C-1.DLL's dependency. Apart from some system dlls, the only one it depends on is LIBGEOS-3-2-2.DLL which lies next to it. So clearly, no missing modules. I'm thinking if it's the way of dll loading is changed for the lates libgeos. Because after I donwloaded and installed OSGeo4W, I included the geos dll in this software, then it worked. But I'm not sure if it will introduce inconsistency in the future
Georgie Porgie
no need to paste exact paths if you use ctypes.util.find_library
dcolish
A: 

Same issue here. Could you maybe be so kind as to share the correct DLL? If that indeed solves the problem. Or is installing OSGeo4W the only way?If so what installation procedure did you follow?

snirp
Resolved by grabbing the libgeos library from the spatialite site and unpacking both dll's to system32.
snirp