Search code examples
pythonamazon-web-serviceslambdapipaws-lambda-layers

"Unable to import module 'lambda_function': libasound.so.2: cannot open shared object file: No such file or directory",


I have created a lambda layer with the following python packages using pip3: google-cloud-texttospeech and azure-cognitiveservices-speech

When I use this layer with python3.8 lambda function, I get the error saying,

{
  "errorMessage": "Unable to import module 'lambda_function': libasound.so.2: cannot open shared object file: No such file or directory",
  "errorType": "Runtime.ImportModuleError"
}

I removed the azure-cognitiveservices-speech package and the layer works fine with lambda. This means that the culprit is the azure-cognitiveservices-speech package. I couldn't find a way to solve the problem.

Any kind of help will be grately appreciated. Thank you!


Solution

  • So you need to install the package manually on your system and package the same with your lambda zip file as per the documentation

    Once installed you can package your python code and the .so files together and upload to AWS lambda. The folder structure for your reference should look like this.

    myawesomefunction.py
    libasound.so.2