How can I use external python libraries in aws lambda function? I have tried to make a virtual environment using the following command:
py -m venv .lambda
Then I activate the venv using the following command:
.\.lambda\Scripts\activate
Then I install pyodbc in venv using the following command:
py -m pip install pyodbc
All of this goes well.
Now, when I want to use pyodbc in my aws lambda function I have zip the venv folder (.lambda) and upload it to a layer. I zip the folder by using "Compressed (zipped) folder".
I am uploading the zipped folder by going to layers in aws lambda function and press "create layers".
After creating the layer I use it in my aws lambda function. But even then when I try to import pyodbc library I get the error:
No module named 'pyodbc'
I am importing the library in my aws lambda function using the following command:
import pyodbc