How to create AWS Lambda deployment package that uses Couchbase Python client


I’m trying to use AWS Lambda to transfer data from my S3 bucket to Couchbase server, and I’m writing in Python. So I need to import couchbase module in my Python script. Usually if there are external modules used in the script, I need to pip install those modules locally and zip the modules and script together, then upload to Lambda. But this doesn’t work this time. The reason is the Python client of couchbase works with the c client of couchbase: libcouchbase. So I’m not clear what I should do. When I simply add in the c client package (with that said, I have 6 package folders in my deployment package, the first 5 are the ones installed when I run “pip install couchbase”: couchbase, acouchbase, gcouchbase, txcouchbase, couchbase-2.1.0.dist-info; and the last one is the c client of Couchbase I installed: libcouchbase), lambda doesn’t work and said:

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

Any idea on how I can get the this work? With a lot of thanks.


I’m not familiar with AWS lambda, but if you haven’t actually installed libcouchbase you might also need to set LD_LIBRARY_PATH (i.e. the linker runtime path) to indicate to the kernel where to find This will usually be in <C_SDK_INSTALL_PATH>/lib


Hi, Did it get it to work? I’m about to attempt the same.


Has anyone been able to connect from AWS Lambda Python 3.6 to couchbase?

I get the same error as this,

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

There is no way to ssh into aws lambda machines, so I has someone able to achieve to set the a library path <C_SDK_INSTALL_PATH>/lib


You have to install libcouchbase there:

We have yum repositories and also you have install it directly from RPMs


Thank you for your link, I got this working.

For others who are searching to fix this error, run the following in your docker container running Amazon AMI (I used docker image dacut/amazon-linux-python-3.6, it should be the same in ec2 or any Amazon Linux)

Only needed during first-time setup:

sudo rpm -iv couchbase-release-1.0-4-x86_64.rpm

Will install or upgrade existing packages

sudo yum install libcouchbase-devel libcouchbase2-bin gcc gcc-c++

Then include the files in


and the .so files in


in your lambda deployment package zip file which you will be uploading to S3.

(if you cannot for some reason find the files in /usr/lib64, use this command to check where the files are located - bash-4.2#rpm -ql libcouchbase-devel libcouchbase2-bin )

How to build a Microservice with AWS Lamba