I try to use JIRA library for Python in aws lambda. I create layer in lambda put in it the zip file that the contain the output of this command :
pip3 install -t /home/reham/projectes/jira/python jira
when I run code in lambda i get this error :
{
"errorMessage": "Unable to import module 'lambda_function'"
}
Function Logs
START RequestId: e348111f-e225-4af6-8fc6-8be9cd793464 Version: $LATEST
Unable to import module 'lambda_function': No module named 'jira'
try to use runtimes python3.6 and python3.7 but not work.
could please anyone help me?
Related
For my lambda function I need this library: https://github.com/explosion/tokenizations (Listed under pytokenizations on PyPi)
I've installed it with pip install --target ./package , zipped it and brought it to lambda, but when I run my function (the exact same code works fine on my machine) I get the following error: "Unable to import module 'main': No module named 'tokenizations'"
EDIT: The actual error is "Unable to import module 'main': No module named 'tokenizations.tokenizations'" Wouldn't the normal output be just one time tokenizations?
The other module I'm using through the /package folder is working just fine.
What could be possible causes for this?
I need to call external API and print the output as JSON. I'm using AWS Lambda function to execute this code sample in serverless environment. Following is the code and its return error as
Error message
"errorMessage": "Unable to import module 'lambda_function': No module named 'requests'",
"errorType": "Runtime.ImportModuleError",
"requestId": "399d0ea2-6713-4714-90ee-1b8e9924af13",
"stackTrace": []
Code Sample
import json
import boto3
import requests
from botocore.vendored import requests
BASE_URL = 'https://fakestoreapi.com'
query_params = {
"limit": 1
}
response = requests.get(f"{BASE_URL}/products", params=query_params)
print(response.json())
Some of the post suggested solution as use Python 3.7. I'm using 3.9. Is this 'requests' module not available in Python 3.9? How to use this in Python 3.9? Some of the post suggested to "pip3 install -t python requests" . I'm using Lambda function inside AWS. How to execute this command if require?
There are several options that you can check at https://aws.amazon.com/blogs/compute/upcoming-changes-to-the-python-sdk-in-aws-lambda/.
Using a Lambda layer would be your best choice.
When I'm trying to import rasterio in AWS Lambda I receive the following error:
Unable to import module 'lambda_function': No module named 'rasterio._base'
At first, I received the following error:
Unable to import module 'lambda_function': No module named 'rasterio'
So I tried to pip install the module, compressed it into a zip, and upload it as a layer(I did the same for the requests module and it worked just fine),
but now I'm getting:
Unable to import module 'lambda_function': No module named 'rasterio._base'
I've also tried:
Creating an empty virtual environment -> pip installing rasterio ->
compressing the module.
Installing different versions of rasterio
When I try to import rasterio._base through the CLI it works, but for some reason it fails to compile in the lambda.
Any suggestions?
use rasterio-lambda-layer - see https://github.com/addresscloud/rasterio-lambda-layer
Response:
{
"errorMessage": "Unable to import module 'lambda_function'"
}
Unable to import module 'lambda_function': No module named 'plivo'
Download the Twilio Library on Ubuntu machine using the command (with sudo pip3 install plivo-t) and ZIP the Twilio library.
The libraries add to layers and connected to current Lambda function. Please find my lambda function code in above image.
When I test the function shows error like as "Unable to import module 'lambda_function': No module named 'plivo'". Please find the execution result in the above image.
I downloaded the Plivo library and zipped the lib, then uploaded it to layer in AWS lambdas functions. I connected the layer to current functions, then when I test the function, it shows an error like "Unable to import module 'lambda_function': No module named 'plivo '".
Code:
import json
import requests
import plivo
#from twilio.rest import Client #I added Layers. That is twilios library zi
def lambda_handler(event, context):
return {'statusCode': 200, 'body': json.dumps('Hello from Lambda!') }
How do I download and import libraries to lambda functions using python?
Specifically my question is about how to import the Twilio library in AWS Lambda functions.
Also had the same issue. And my reason was with folders/files permissions. I just set them all to 777 (chmod -R 777 python/). And did the same as in documentation: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
And it worked!
What is the structure of your .zip? Does it have a top-level folder named "python" that everything else is in? Or is it inside this path of folders: python/lib/python3.7/site-packages? Be sure you match the necessary structure for the layer source code as described here: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-path
To include libraries in a layer, place them in one of the folders
supported by your runtime. Python – python,
python/lib/python3.7/site-packages (site directories)
Example Pillow
pillow.zip
│ python/PIL
└ python/Pillow-5.3.0.dist-info
I am trying to execute python script using mule component but I am getting exception.The exception details are ImportError: No module named itty.Help me to resolve this issue
You need to install this library
pip install yoloimport