Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Layer Unable to import module 'lambda_function': No module named 'pyarrow.lib'

I followed the following steps to create a layer to use in my AWS Lambda function.

  1. Downloaded the pyarrow library to python folder using the following command

    pip install pyarrow==5.0.0 -t python

  2. Then recursively zipped the python folder

    zip -r pyarrow.zip python/

  3. Uploaded the zipped file using the AWS Lambda UI and successfully created a layer.

  4. Added the layer to my lambda function.

However when I try to import pyarrow I get the following error.

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

I downloaded the the zip file. I can see the pyarrow folder in it. But for some reason Lambda can't find the pyarrow. Any suggestions or advice where I could have made a mistake?

like image 790
Tech Guy Avatar asked Sep 10 '26 13:09

Tech Guy


1 Answers

Assume your code is in "function_code" folder in some path

  1. pip install pyarrow==5.0.0 -t function_code/
  2. cd function_code
  3. zip -r funcition_code.zip * (you should not zip the folder but only its contents)
  4. Upload the zip
like image 80
omuthu Avatar answered Sep 12 '26 02:09

omuthu