No module named 'boto3'

0

Hi,

This may be a dumb question. I want to use boto3 library in the Lambda function (import boto3) but have encountered this error:

[2019-06-20T15:52:17.548-07:00][FATAL]-lambda_runtime.py:347,Failed to initialize Lambda runtime due to exception: No module named 'boto3'

Here is my setup.
--Jetson Nano running JetPack 4.2
--Python 3.7 with boto3 installed (no problem running locally)
--Greengrass 1.9.1
--Lambda function config:
----Python 3.7 runtime
----both UID and GID = 1000 (nvidia)
----memory = 2048 MB and timeout = 10 minutes (more than enough)

Thank you!,
Adrian

asked 5 years ago8395 views
11 Answers
0

The problem disappears on TX2 (also running JetPack 4.2).
I guess Greengrass is still somehow not very compatible with Nano then?

answered 5 years ago
0

Was boto3 installed globally or locally for the nvidia user?

Another option would be to bundle the boto3 library along with the lambda.

answered 5 years ago
0

Hi,

Boto3 is installed both globally and for Nvidia user.
It's OK. I will just use TX2 instead of Nano.

Edited by: Adrian-LI on Jun 24, 2019 10:10 AM

answered 5 years ago
0

Hi ,

We're investigating the issue. Presently, Greengrass has been tested on the TX2.

What's the output of:

pip install boto3
python --version
python3 --version

Thanks,
KR-AWS

AWS
KR-AWS
answered 5 years ago
0

I faced the same error in my Jetson Nano. It was caused because boto3 was installed for Python 3.6 but NOT for Python 2.7. To solve it, you have to make sure you're installing it for 2.7 version:

This shall output Python 2.7:

python --version

Next, run below commands:

sudo apt-get install python-pip
sudo python -m pip install boto3

To test it, simply start a new terminal and type:

python
import boto3

Regards.

answered 5 years ago
0

Hello,
One way to make sure you don't run into import not found is to bring the dependency with your lambda code.

in the root of your zip file for your lambda code, something like:

pip install boto3 -t .

Thanks,
Reda

answered 5 years ago
0

I am getting an error [FATAL]-lambda_runtime.py:108,Failed to import handler function "ModbusMasterLambda.function_handler" due to exception: No module named boto3 with Greengrass
version Greengrass-Linux-armv7l-1.8.2.tar.
lambda Python 2.7

I also tried with the deployment package(Layer) but the issue is the same.
facing this issue with Greengrass only

Thank You
Visual

visual
answered 4 years ago
0

Hi visual,

Did you try the above:
This shall output Python 2.7:

python2.7 --version

Next, run below commands:

sudo apt-get install python-pip
sudo python2.7 -m pip install boto3

What OS are you running?

Thanks,
KR-AWS

AWS
KR-AWS
answered 4 years ago
0

Hi KR-AWS

Thanks for your response.

I am getting this error on AWS Lambda and as per AWS Documents
Link:https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

"If your function depends on libraries other than the SDK for Python (Boto 3), install them to a local directory with pip, and include them in your deployment package"
facing this issue with Greengrass only. individually the functionality is working without Greengrass.

But I also tried using the deployment package.

Thanks
Visual

Edited by: visual on Jan 8, 2020, 9:19 PM

Edited by: visual on Jan 8, 2020 9:27 PM

visual
answered 4 years ago
0

Hi Visual,
Greengrass doesn't follow exactly what Lambda on the cloud does, for example Greengrass does not bundle boto3 library; you must include it yourself in the zip file that you upload to Lambda. The easiest way to do this is to navigate to your own code and then do pip install -t . boto3 which will install boto3 and all of its dependencies into your current directory. Then you can zip up all the code and put it on Lambda. The layout of your zip file should look like

your_code.py, boto3 (directory), botocore (directory), ... other files and directories

Hopefully that makes sense. You can follow this guide for using boto3 and other AWS services from Greengrass: https://docs.aws.amazon.com/greengrass/latest/developerguide/create-config-lambda.html

--
Michael

Edited by: MichaelDombrowski-AWS on Jan 9, 2020 9:49 AM

Additionally, Greengrass does not use Lambda layers, so all of your code that you need to be deployed to Greengrass must be in the lambda function zip itself and not in a layer.

AWS
EXPERT
answered 4 years ago
0

Hi MichaelDombrowski-AWS,

Thanks a lot for your response. finally the issue is resolved.

visual
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions