4

Im creating a lambda function to connect to an RDS Postgresql instance, using psycopg2 library. When i tried on my local desktop, it works fine, but when i upload the code to the AWS lambda and test it, it throws the error:

Unable to import module 'lambda_function': No module named 'psycopg2._psycopg'

I tried to pip install psycopg2 to the local folder on my pc where I saved the local copy of my lambda_function, and then created a zip out of it and uploaded it. But still its not working. Anyone who has faced similar issue, please advise.

I have installed python 3.7 (32 bit) on my local. Not sure if AWS version of python is 64 bit or not.

Nikhil Ravindran
  • 392
  • 3
  • 12

1 Answers1

5

I found out the issue on why it wasnt working. My local python instance is 3.7, so obviously it will run code developed using 3.6 as well. And the psycopg2 build library that i got from jkehler/awslambda-psycopg2 was built for python 3.6 and while im uploading my code to AWS lambda, i was selecting Python 3.7 as Runtime environment. When i change the runtime to 3.6 the code worked without any issues. So closing the issue

Nikhil Ravindran
  • 392
  • 3
  • 12