Amresh Kadian
Amresh Kadian

Reputation: 191

AWS Lambda Python error - Runtime.ImportModuleError

I am running the AWS Step by step guide for following link.

I am currently on Step 4. - Create the Lambda function that splits input data

I am running on a Windows 10 machines with Python installed:

pip 20.2.3 -  (python 3.9)

The Lambda function on AWS is failing with following:

{
  "errorMessage": "Unable to import module 'lambda_function': No module named 'fsspec'",
  "errorType": "Runtime.ImportModuleError"
}

Function Logs

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'fsspec'

Please recommend any solution.

Upvotes: 0

Views: 5913

Answers (2)

Rita Carolina
Rita Carolina

Reputation: 121

My solution was to add the fsspec library at a custom layer. First of all you need to create a Custom Layer. Open your terminal:

mkdir python
cd python
pip3 install fsspec -t .

Install inside this folder any other file you may need.

cd ..
zip -r fsspec_layer.zip python

This is the zip file you are going to use to create your custom layer. Do the following:

  1. Go to AWS LAMBDA -> Layers
  2. Create the Layer

Lambda Layer

  1. At your Lambda Functions Panel Select Layer

Lambda Functions

  1. Select the layer you created

enter image description here

Then try to execute it again.

Upvotes: 3

Amresh Kadian
Amresh Kadian

Reputation: 191

The issue was with the file permissions. I was zipping the files on Windows 10 machine and due to some reason the files are not having execute permission. The function is able to run once the permissions are set correctly using a Mac:

Commands used - 

 1. chmod -R +x *.py
 2. zip xyz.zip *

Upvotes: -1

Related Questions