Errors when using AS Python client for AWS Lambda with SAM CLI on Ubuntu 18.04

I am trying to build local development environment for AWS Lambda deployments that includes Aerospike client. I made a new install of Ubuntu 18.04.3 at VirtualBox, upgraded.

Following AWS instructions, I got SAM CLI properly working with docker at that machine.

I installed PyCharm 2019.3.1 via Ubuntu Applications and selected AWS toolkit, while specifying an IAM user to access AWS. I selected the pre-installed Python 3.6 for the “Lambda Hello World” project. I can successfully run “Hello World” app and I am getting the correct JSON response in PyCharm console:

{“statusCode”:200,“body”:"{“message”: “hello world”}"}

So far it all good.

Now I installed aerospike python client:

sudo apt install python3-pip

sudo apt install libssl-dev zlib1g-dev curl

pip3 install aerospike==3.6.0

and added

import aerospike

to hello_world/



line to hello_world/requirements.txt

these are the only changes I made.

After that I got an error when running the same sample “Hello World” app:

Unable to import module ‘app’: cannot open shared object file: No such file or directory

I tried copying to the “project home” folder at hello_world/

cp /usr/lib/x86_64-linux-gnu/ [...]/hello_world/

but then I got another error from SAM:

Unable to import module ‘app’: cannot open shared object file: No such file or directory

Adding also to […]/hello_world/ ends up with

Unable to import module ‘app’: /lib64/ version `GLIBC_2.25’ not found (required by /var/task/

What I am doing wrong and how to get Aerospike Python client work for AWS Lambda / SAM CLI docker environment on Ubuntu 18.04?

Found a simple answer to that:

Build function inside a container

checkbox in PyCharm HelloWorldFunction project configuration, SAM CLI tab. Once checked, with the above changes I am getting as expected

{"statusCode":200,"body":"{\"message\": \"hello world\"}"}

AWS says about this checkbox:

This is useful if the function depends on packages that have natively compiled dependencies or programs

and this is essentially the same like running

sam build --use-container (more)

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.