简体   繁体   中英

AWS Lambda Layer: No module named 'psycopg2._psycopg'"

I have a library that I downloaded here:

psycopg2

I tried all stakeoverflow suggestions thus far but they didn't work.

I placed it in a folder like this then zipped it to a python.zip folder on windows. The libraries inside are unzipped.

在此处输入图像描述

Then I created a lambda layer like this:

在此处输入图像描述

I've made sure that the runtime for layer and the function are the same, can someone please assist? Been struggling with this for more than a day.

AWS Lambda uses the Amazon Linux environment, if you are using windows and create a zip file of dependencies it might not work while you run your lambda function. It will be better if you create the layer as a docker env. Please check below:

https://www.geeksforgeeks.org/how-to-install-python-packages-for-aws-lambda-layers/

You need To compile it within a similar architecture as the lambda runtime. I would log into an Amazon Linux EC2 install psycopg there into a specific directory, then copy those files to your Lambda layer on your Windows machine.

Can send more specific steps if you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM