1

I have a problem with the plpygis library for python. Whenever I'm trying to convert a plpygis Point type into its shapely counterpart, I get the following error:

ERROR: plpygis.exceptions.DependencyError: Dependency 'Shapely' is not available.

The code is executed within a PL/Python function in Postgres. The code looks like this:

CREATE or REPLACE FUNCTION test(n int)
 RETURNS text
AS $$
from plpygis import Geometry, Point
coordinates = []
for i in range(n):
 srows = plpy.execute("...")
 for i in srows:
 point = Geometry(i['geom'])
 if point.type != "Point":
 pass
 coordinates.append(point.shapely)
return coordinates
$$ LANGUAGE plpython3u;

It fails on the line coordinates.append(point.shapely). The shapely library is installed in the same pip env as all other packages, and everything is up-to-date. Importing shapely by itself works perfectly fine.

I took a look into the plpygis source code and it determines the error by checking if this import is working:

 from shapely.geos import lgeos, WKBWriter

I checked it manually and the import didn't work, which is then the reason for the DependencyError.

Does anyone have an idea on why this is happening?

asked Jul 17, 2023 at 16:33

1 Answer 1

1

plpygis author here. Can you try a more recent version of plpygis? I suspect the issue is due to missing support for Shapely 2.x, but that has now been added.

answered Apr 21, 2024 at 19:24
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, I can't validate your answer, since I don't have access to the database anymore this was running on. It seems like it would've fixed the issue, though. Thank you very much for providing an answer after all this time.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.