psycopg2 library needs to be compiled in Amazon Linux using a specific Python version.
I created the script to automatically compile the library using any Python version.
Due to AWS Lambda missing the required PostgreSQL libraries in the AMI
image, we needed to compile psycopg2 with the PostgreSQL libpq.so library
statically linked libpq library instead of the default dynamic link.
- Install Docker.
- Download the
PostgreSQL source code (.tar.gz),
rename to postgresql.tar.gz and put it into
sourcesfolder. - Download the
psycopg2 source code (.tar.gz),
rename to psycopg2.tar.gz and put it into
sourcesfolder.
- compile:
make compile PYTHON=<version>(find available versions here). - compile with SSL support:
make compile PYTHON=<version> SSL=1
custom compiled psycopg2 library is now ready in the build folder.
Makefile is not available on Windows, there're few options:
- use WSL
- run docker commands in
makefilemanually.