Lambda doesn't recognize python dependency - python

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?

Related

import rasterio in AWS Lambda

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

ImportError: No module named 'kzyvad'

I want to start up a project, which imports a module named kzyvad. It occurs error ImportError: No module named 'kzyvad'. However, if I execute pip install kzyvad, it returns ERROR: Could not find a version that satisfies the requirement kzyvad.
Did someone ever successfully install kzyvad?
I don't know where you found your module but I looked for it and I could not find it, I think the guy who wrote 'kzyvad' did a mistake while writing, and if pip gives you this error, it means it doesn't exist.
If this kzyvad.py is written by you, then keep this file/module in a same folder and do this in main.py file:
from kzyvad import *
You can use it's functions and classes in your main.py file

Unable to import module 'lambda_function': No module named 'twilio' on AWS with python

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

No module named 'azure.eventhub'; 'azure' is not a package

I am trying to execute this example using Python 3.7 with Pycharm and azure-eventhub 1.2.0 package.
When I try to run it, I get this error:
ModuleNotFoundError: No module named 'azure.eventhub'; 'azure' is not a package
This is the problematic line:
from azure.eventhub import EventHubClient, Receiver, Offset
What could be happening?
This is my project interpreter
Using pip freeze:
As I known, there is a case which will cause your issue.
The Python Interpreter searches the available packages, objects and methods in the paths of sys.path in order, you can print the value of the sys.path variable to see the order after import sys.
So if there is a Python script named azure.py prior to the real azure package, you will get the issue ModuleNotFoundError: No module named 'azure.eventhub'; 'azure' is not a package.
Here is my steps to reproduce this issue.
I created a Python script named azure.py in the current path which only have one line code print('pseudo azure package').
Then, I opened my Python interpreter in the current path and type from azure.eventhub import EventHubClient, Receiver, Offset, then to get the issue as below.
It also will happen in Pycharm, even using virtualenv, please check whether exists a file called azure.py or azure.pyc in your current path or the paths in the order of sys.path list.

Python: installing multiprocessing

I need to import the multiprocessing module in Python 2.5.
I've followed the instructions here exactly: http://code.google.com/p/python-multiprocessing/wiki/Install
make and make test run without errors. I've also edited $PYTHONPATH to include the directory where the package is installed.
But 'import multiprocessing' still says: "ImportError: no module named multiprocessing".
What am I doing wrong? Is there some step missing from these instructions? I haven't installed a Python module before.
Navigate to the directory containing the package then type:
python setup.py install
This info was contained in the INSTALL.txt file.
http://code.google.com/p/python-multiprocessing/source/browse/trunk/INSTALL.txt
perhaps you can try:
import sys
sys.path.append('/path/to/processingdotpylibs/')
import processing

Categories

Resources