Unable to import module 'lambda_function': No module named '_awscrt'

973 views Asked by At

I'm working with this article Asynchronous Amazon Transcribe Streaming SDK for Python.

I'm trying to create a lambda layer for the required libraries.

I used the following command:

pip3 install amazon-transcribe aiofile -t .

But I get the following error when I use the layer in my lambda function:

Unable to import module 'lambda_function': No module named '_awscrt'

The same works fine with virtual environment locally. I'm not sure what's the exact issue.

I even tried installing awscrt separately but it didn't work.

Any kind of help will be greatly appreciated. Thanks!

2

There are 2 answers

0
Reyansh Kharga On BEST ANSWER

I built the layer on Amazon Linux and it worked fine!

The troubleshooting guide in the repo helped:

The caio linux implementation works normal for modern linux kernel versions and file systems. So you may have problems specific for your environment. It's not a bug and might be resolved some ways:

1. Upgrade the kernel
2. Use compatible file system
3. Use threads based or pure python implementation.
1
Dillon Bourne On

Lambda layers .zip files need to follow a specific directory file structure. Look at this section of the documentation to see how it should be structured for Python. This might be your problem.