jkehler / awslambda-psycopg2

1.1k stars 360 forks source link

How to fix the following error. No module named 'psycopg2._psycopg' #79

Open aakashdusane opened 1 year ago

aakashdusane commented 1 year ago

Getting the following error: No module named 'psycopg2._psycopg' Python version: 3.9 Architecture: Arm64

jakebelman commented 1 year ago

I wasn't able to resolve the issues I was having with this, but I was able to set up psycopg2 using klayers.

Klayers is a compilation of python packages built for lambda. They're given as ARNs - to add them, you can scroll to the bottom of your Lambda function in the Lambda console to Layers, click 'Add Layer' in the top-right, select 'Specify an ARN', then paste the ARN for the package you want.

You can find them in this repo: Klayers Repo

Or you can get a simple list by pasting the API link in your browser: https://api.klayers.cloud//api/v2/{YOUR PYTHON VERSION}/layers/latest/{YOUR AWS REGION}/html Enter the version of python in the form p0.0 (e.g. p3.8) and the region in the aws shortform (e.g. eu-west-1).

flamron commented 1 year ago

Getting the following error: No module named 'psycopg2._psycopg' Python version: 3.9 Architecture: Arm64

If you use ARM64 try to change it to x86_64