Tanmay Bordekar
Tanmay Bordekar

Reputation: 91

Lambda function failing with /lib64/libc.so.6: version `GLIBC_2.18' not found

I am trying to create a layer of simple-salesforce (Python Library) in AWS lambda, and trying to use it (import it) from my python code. I am having windows machine.

Though I read that there might be issues due to compilation windows so I install ubuntu1804 from windows store and then went ahead with creating zip for lambda layers. (zip is created for python folder with structure "python/lib/python3.6/site-packages/......")

I am using Python 3.6. I went through few articles for this issue but could find any resolution. this Video helped me creating a layer for Pandas & requests in AWS successfully with minor tweaks in pip commands I used

sudo python3 -m pip install simple-salesforce -t build/python/lib/python3.6/site-packages

Exactly same process i used for Simple salesforce and I am getting below error is as below:

Unable to import module 'lambda_function': /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /opt/python/lib/python3.6/site-packages/cryptography/hazmat/bindings/_rust.abi3.so)

Edit: -- Another approach I tried using .whl though this was not giving above error but giving error as "request module not found" and when I add request module layer it gives error authlib not found. (request layers work fine if I comment salesforce related things. Even tried uploading as simple layer same authlib issue I got)

Edit : Lambda code I am using is as below

the code I am using is basic code which doesnt have any logic with empty imports

import json
import pandas as pd
import requests as req
from simple_salesforce.format import format_soql

def lambda_handler(event, context):
    #TODO

Upvotes: 7

Views: 17653

Answers (4)

Rayiez
Rayiez

Reputation: 1599

Adding these to requirements.txt worked for me

bcrypt==3.2.2
cryptography==3.4.8

Upvotes: 2

MaFF
MaFF

Reputation: 10086

AWS lambda functions are like virtual environments, they do not come with the .so files which are kernel level packages. When installing the python packages you have to make sure the system dependent files are installed with it. This can be achieved by passing the argument --platform to pip install.

From AWS post How do I add Python packages with compiled binaries to my deployment package and make the package compatible with Lambda?:

To create a Lambda deployment package or layer that's compatible with Lambda Python runtimes when using pip outside of Linux operating system, run the pip install command with manylinux2014 as the value for the --platform parameter.

pip install \
    --platform manylinux2014_x86_64 \
    --target=my-lambda-function \
    --implementation cp \
    --python 3.9 \
    --only-binary=:all: --upgrade \
    simple-salesforce

Upvotes: 5

Pavan Agarwal
Pavan Agarwal

Reputation: 71

I also received the same error while installing pysftp on lambda which uses cryptography library(python) the error was similiar to (required by /opt/python/lib/python3.6/site-packages/cryptography/hazmat/bindings/_rust.abi3.so)

The solution that worked for me is 1] pip uninstall cryptography 2] pip install cryptography==3.4.8 The following github link explains it in detail https://github.com/pyca/cryptography/issues/6390

Upvotes: 7

Tanmay Bordekar
Tanmay Bordekar

Reputation: 91

I changed my code to not use simple_salesforce library and work out all the logic with Requests ( using Salesforce REST APIs). This is not really ideal but I could get it working as I had some deliveries to meet.

Upvotes: 0

Related Questions