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

AWS Lambda with psycopg2 (compiled with PostgreSQL 13.4)

Open billglennon opened this issue 3 years ago • 4 comments

I am basically trying to do the following for AWS Lambda for psycopg2.

I am trying with the following source code bases and I get the error below. Python 3.8.1 Psycopg2 2.9.3 PostgreSQL 13.4

psycopg2 setup.cfg config file psycopg2-2.9.3/setup.cfg pg_config = static_libpq = 1 libraries = ssl crypto

However, when I try with PostgreSQL 11.14 it works. Python 3.8.1 Psycopg2 2.9.3 PostgreSQL 11.14

I also tried with PostgreSQL 12.9 and I get the same error.

Of the web sites I found with this process, all the database versions were PostgreSQL 11 or lower.

Did something change in 12 and above to cause this issue with psycopg2?

Any help/pointers would be appreciated.

Error Message:

import psycopg2 Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/site-packages/psycopg2-2.9.3-py3.8-linux-x86_64.egg/psycopg2/init.py", line 51, in from psycopg2._psycopg import ( # noqa ImportError: /usr/local/lib/python3.8/site-packages/psycopg2-2.9.3-py3.8-linux-x86_64.egg/psycopg2/_psycopg.cpython-38-x86_64-linux-gnu.so: undefined symbol: pg_tolower

billglennon avatar Jan 07 '22 19:01 billglennon

I'm experiencing the same issue with

  • PosgreSQL 12.8
  • Psycopg2 2.9.3
  • Python 3.9 I'm on Amazon Linux 2.

m-ajay avatar Jun 16 '22 18:06 m-ajay

Any updates for this?

EAblir avatar Jul 21 '22 06:07 EAblir

I also am getting the above error message. Trying to compile Psycopg2 on Amazon Linux 2 with the versions:

PosgreSQL 13.7 Psycopg2 2.9.3 Python 3.9

Things I've tried:

  • Lower versions of Postgres. But unable to generate a compiled version that successfully runs without this Psycopg2 error message for anything above Postgres 11.x.
  • Psycopg2.8.5
  • Downloading/installing from source, as well as using yum install.

Same errors each time.

christine-le avatar Jul 25 '22 20:07 christine-le

I managed to go with the command:

pip3 install --target ./package psycopg2-binary

Then I copy everything from package directory and place it at level of my lambda code. So I get at top level of lambda directories psycopg2 and psycopg2.binaries.lib, packed as zip and upload it. Looks like it is easier than use this project.

sphinks avatar Aug 07 '22 13:08 sphinks