aws-psycopg2 icon indicating copy to clipboard operation
aws-psycopg2 copied to clipboard

ModuleNotFoundError in AWS Python 3.12 images

Open bassicallychris opened this issue 6 months ago • 4 comments

When using aws-psycopg2 in the AWS public.ecr.aws/lambda/python:3.12 image the error ModuleNotFoundError: No module named 'psycopg2._psycopg' is produced when using the sqlalchemy package.

bassicallychris avatar Feb 09 '24 22:02 bassicallychris

@bassicallychris Without offering a solution using this library, when using public.ecr.aws/lambda/python:3.12 I just use the psycopg2-binary

alexandreczg avatar Mar 07 '24 21:03 alexandreczg

Thanks for the response @alexandreczg. According to the psycopg2 documentation psycopg2-binary isn't meant for production use.

If you are the maintainer of a published package depending on psycopg2 you shouldn’t use psycopg2-binary as a module dependency. For production use you are advised to use the source distribution.

ref psycopg2 documentation

Ideally we are able to leverage a version of psycopg2 for aws-lambdas that is based on the source distribution.

bassicallychris avatar Mar 08 '24 04:03 bassicallychris

ah, that's good to know, haven't read that advisory. I guess gotta find a way to build it myself, seems like this lib here has lost support.

alexandreczg avatar Mar 08 '24 17:03 alexandreczg