Libgeos_c-1.dll could not be loaded by Python

I am building my first GeoDjango project, but I am desperate.

I installed PostgreSQL 9 and PostGis 1.5 using the one-click installer on Windows. So there is everything. 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 specified line. It is simply "CDLL (lib_path)". Obviously lib_path is GEOS_LIBRARY_PATH.

So, I am creating a simple test:

 from ctypes import CDLL lgeos = CDLL('libgeo path') 

Still the same problem. Therefore, it simply cannot use CDLL to load this DLL at all using python. At this stage I do not know what to do. Please, help.

+4
source share
5 answers

Same problem. Maybe you are so kind to share the correct dll? If it really solves the problem. Or install OSGeo4W the only way? If so, what installation procedure did you follow?

0
source

By default, after setting the variable GEOS_LIBRARY_PATH using doble '\' slashes it works for me, but now it runs this object 'error' of this module, it does not have the attribute 'OSMGeoAdmin'

+3
source

I just ran into the same problem after installing Postgresql 9.1 and postgis 2.0 through Windows installers. No need to download anything. All you have to do is add this directory to the Windows path: C:\PostgreSQL\9.1\bin or wherever the libgeos_c-1.dll file is located. You may need to reboot if you want the new environment variables to take effect for your development environment. For the command line, just open a new command line.

Performing this method makes the GEOS_LIBRARY_PATH setting optional since the required files are already in the Windows path.

This may not have worked for the OP in 2010, but for others who will face the same problem in 2012, this is probably the easiest solution.

+2
source

Various things come to my mind, the most obvious: you entered the path to the DLL file, and not just the folder in which it is located. No crime meant to be safe.

Then you can also get this error if there are unresolved dependencies, that is, the LoadLibrary DLL fails because it does not have another library on which it depends. You can easily find this using Dependency Walker . The download of libgeos is dependent on and looks for missing modules, error messages, etc. - for example, libgeos-XYZ.dll may be missing.

+1
source

I had the same problem and solved it:

  • Reinstalling http://trac.osgeo.org/osgeo4w/ (my installation folder is C:\OSGeo4W64\ )
  • adding a line:

    GEOS_LIBRARY_PATH = 'C: \ OSGeo4W64 \ bin \ geos_c.dll'

to settings.py

(after this answer: fooobar.com/questions/653011 / ... )

This is also mentioned in the official documentation :

When GeoDjango cannot find GEOS, this error occurs:

ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings. The most common solution is to correctly configure the library environment settings or set GEOS_LIBRARY_PATH in the settings.

0
source

All Articles