[python] Shapely doesn't work correctly

I installed shapely with pip. On default python interpreter I get this errors:

>>> from shapely. geometry import Point
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/defaultuser/.local/lib/python3.8/site-packages/shapely/geometry/__init__.py", line 4, in <module>
    from .base import CAP_STYLE, JOIN_STYLE
  File "/home/defaultuser/.local/lib/python3.8/site-packages/shapely/geometry/base.py", line 20, in <module>
    from shapely.coords import CoordinateSequence
  File "/home/defaultuser/.local/lib/python3.8/site-packages/shapely/coords.py", line 10, in <module>
    from shapely.geos import lgeos
  File "/home/defaultuser/.local/lib/python3.8/site-packages/shapely/geos.py", line 99, in <module>
    _lgeos = load_dll('geos_c', fallbacks=alt_paths)
  File "/home/defaultuser/.local/lib/python3.8/site-packages/shapely/geos.py", line 54, in load_dll
    raise OSError(
OSError: Could not find lib geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'].

On official PyPI page is written:

Linux, OS X, and Windows users can get Shapely wheels with GEOS included from the Python Package Index with a recent version of pip (8+):

So I don’t understand why I’d need to compile and install GEOS.

But anyway, I decided to compile GEOS and it changed nothing even if I install shapely this way:

GEOS_CONFIG=/usr/local/bin/geos-config pip install install shapely

If I search the library with find_library, it works:

>>> from ctypes.util import find_library
>>> find_library('geos_c')
'libgeos_c.so'

And on terminal:

geos-config --clibs
-L/usr/local/lib64/ -lgeos_c

Has somebody any idea what I did wrong?

Is it easy to retrieve Fedora’s RPM package, adapt it to SailfishOS and install?

Ok, I got it.

shapely search for library saved on the same path. On my case:

/home/defaultuser/.local/lib/python3.8/site-packages/shapely/.libs/

But directory .libs didn’t exist. Once created, with symlinks to both libraries (libgeos_c.so.1 and libgeos.so) it work.

1 Like