In my CloudWatch logs I am getting this error for my AWS Lambda:
Runtime.ImportModuleError: Unable to import module 'app.main': No module named 'psycopg2._psycopg'
I have uploaded a aws_lambda_package.zip
file that contains my FastAPI app and the dependencies from my requirements.txt
The app is running in a Python 3.10 environment and I am using psycop to connect to a PostgreSQL database on RDS.
To try and solve this bug, I created a Python 3.10 virt environment and installed psycopg2-binary in it with pip install psycopg2-binary -t python
. I then created a .zip package and added it as a layer for my AWS Lambda function, but it still hasn’t worked.