For me it worked after running the below code inside of the lambda function directory and deploying the code anew.
pip3 install --platform manylinux2014_x86_64 --target=./ --implementation cp --python-version 3.12 --only-binary=:all: --upgrade psycopg2-binary