Shapely: windows and geos_c.dll

Created on 16 Nov 2015  路  8Comments  路  Source: Toblerity/Shapely

Hey Guys,
I failed to get shapely imported to python even with the GEOS_LIBRARY_PATH variable set to my geos_c.dll. He complains about a missing GEOSversion function. However, setting GEOS_LIBRARY_PATH to the geos_c.dll during installation with pip worked fine. At the beginning he also complained about the same problem there.

What worked for me:
I changed the libgeos.py (geos.py in my version) file to try to load geos_c.dll instead (in the win32 section). That worked for me now but maybe this would be an improvement to try to load both.

Not sure about gdal dll's or how they are usually named on windows since this is my first try with GDAL and shapely. Binaries were precompiled from gisinternals (also the GDAL python bindings pointed this as an option to get them running).

Most helpful comment

on windows 10, python 3.6.5 64bit

  • install osgeo4w
  • add installed folder to path e.g. C:\OSGeo4W64\bin (must contain geos_c.dll)
  • restart command line

enjoy

All 8 comments

@TheSy we only designed GEOS_LIBRARY_PATH to be used at install time, that's part of the problem. The other part is that, as you see, we're keying on the name "gdal.dll" in https://github.com/Toblerity/Shapely/blob/maint-1.5/shapely/geos.py#L130-L138. I don't want to support many variants of the DLL name, but if "geos_c.dll" is very common in the wild, I'm happy to accept a path or PR.

@sgillies not sure about how the dlls are usually named since this was one of my first try with python (usually c++ programmer) and also with GIS libraries in general.

I took a look how the dll is named within the osgeo4w package manager and it looks like it is also named "geos_c.dll". The binaries from gisinternals contained two dll's: geos.dll and geos_c.dll. I did not get shapely running with the geos.dll, also during installation with pip (as far as i remember).

One datapoint. Shapely is patched to use goes_c.dll in https://github.com/conda-forge/staged-recipes/blob/master/recipes/shapely/geos_c.win.patch (and I think Chrisoph Gohlke does the same thing). The reason for that comes down to https://github.com/conda-forge/staged-recipes/blob/master/recipes/geos/cmake.win.patch.

Relevant previous discussion: https://github.com/SciTools/conda-recipes-scitools/issues/29

The OSGeo4W distribution ships it as "geos_c.dll" too.

There's still time for a PR to get this for 1.5.14...

Am I correct in thinking that geos.dll is the C++ library, and geos_c.dll is the C API? In that case linking to geos.dll would be the wrong thing to do.

I worked around this on OSGeo4W (Windows) by copying geos_c.dll to geos.dll. :see_no_evil:

on windows 10, python 3.6.5 64bit

  • install osgeo4w
  • add installed folder to path e.g. C:\OSGeo4W64\bin (must contain geos_c.dll)
  • restart command line

enjoy

Was this page helpful?
0 / 5 - 0 ratings