0

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.

samtoddler
  • 8,463
  • 2
  • 26
  • 21
Amresh Kadian
  • 181
  • 1
  • 2
  • 11
  • 1
    have you looked at this? https://stackoverflow.com/questions/35340921/aws-lambda-import-module-error-in-python – sagar1025 Jan 31 '21 at 04:59
  • 1
    Can you show your actual lambda code? – Marcin Jan 31 '21 at 05:25
  • 1
    if you are following the guide then in this [Step 3: Create a package that contains the required Python libraries](https://docs.aws.amazon.com/pinpoint/latest/developerguide/tutorials-importing-data-create-python-package.html) in #3.8 describes how to package your dependencies. Please check if your uploaded zip to lambda has the dependecies packaged. – samtoddler Jan 31 '21 at 15:14

2 Answers2

2

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.

-1

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 *
Amresh Kadian
  • 181
  • 1
  • 2
  • 11