Grequests on AWS Lambda "Gevent is required" Error - python

I want to use grequests on AWS Lambda. I created venv and reqs.txt and then pip install in a folder named python, then zipped the python folder and uploaded it to a Lambda Layer. After that, I am facing this error:
Gevent is required for grequests.
I already tried this answer on AWS Linux but nothing changed.
Any solution or advice?
Edit: A solution was written, "make zip process on ec2 server, not get the files from ec2 and zip on your local" and I did so. The error messages changed to:
Unable to import module 'lambda_function': No module named 'grequests'
Edit 2: I followed this guide, and facing a new error :)
Unable to import module 'lambda_function': No module named 'zope.interface'
and zope.interface already installed.

Related

"Unable to import module 'lambda_function': cannot import name 'cygrpc' from 'grpc._cython' (/var/task/grpc/_cython/__init__.py)"

I am working on aws lambda function, i install the package but i got error
Unable to import module 'lambda_function': cannot import name 'cygrpc' from 'grpc._cython' (/var/task/grpc/_cython/init.py)
How to solve this type of error?
Are you trying to import it in code without haveing it installed on the lambda container? If you gonna use none std libs you should have you function and its libs installed locally and when zip it and upload it to Lambda.
Docs:
https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html
In addition to an answer marked correct I wanted to mention that for libraries using C-extensions is important that the layer was built on the same type of system as it runs in lambda. For example, if you're trying to build the layer including grpc on MacOS most likely it won't work since lambda is running on Linux. To make the layer working you have to build it in a Linux system (for example, on the virtual machine or in Docker)

Import Python Module at Runtime with AWS Lambda

I am attempting to import the google-cloud-firestore module in a python script on AWS Lambda. I have the module installed in my virtual environment and upload the code/packages in a zip folder, but receive the following error.
I have successfully imported and executed a script with the requests module using the same approach.
I have attempted to uninstall and reinstall the following modules to my virtual environment and still have no luck: google-cloud-firestore, grpcio, google-cloud-core.
Does anyone have a solution to this problem? What could I be missing here?
This thread gives me the impression that the google-cloud-firestore module cannot be used in a zip file. If this is the case, can I install the module at runtime?
Thank you for any and all advice!

boto3 module not found

My Pyspark EC2 instance got terminated (my fault) and I am trying to build another one. I have Spark running and now am trying to run a simple Pyspark script to access S3 bucket. The machine has Python 3 installed and I installed boto3 but I get compilation error for the line below.
from boto3.session import Session
No module named 'boto3' .
Also, I get a logger error saying invalid syntax when I do the following
print rddtest.take(10)
Not sure what I am missing. Thanks in advance.
You might have many python installations in your machine. pip might be installing boto3 for python3.6 while you are currently executing python3.7

GIBCXX_3.4.20 not found error in AWS Lambda

I'd like to use the Python package (Konlpy) in AWS Lambda. However, the following error occurs:
"Unable to import module 'lambda_function': /usr/lib64/libstdc++.so.6: version 'GLIBCXX_3.4.20' Not found (required by /var/task/_jpype.so)"
How can I fix it?
enter image description here
The AWS Lambda is deployed in a clean environment. It does not have the package Konlpy, it has no idea what you are trying to import.
In order to achieve this, you can create a Cloud Formation Stack. This can bundle up your code and allow you to deploy dependencies for your lambda.

pymssql package does not work with lambda in aws

How do we create a pymssql package for lambda. I tried creating it using
pip install pymssql -t . When I run my lambda function it complaints saying that
Unable to import module 'lambda_function': No module named lambda_function
I follow the steps on this link
http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html
I have a windows machine
Glad that it worked for you, could you please share the working process for your, me too tried different trial and error steps and ended up with the following one which is working fine in AWS Lambda, I am using PYMSSQL package only.
1) did 'pip install pymssql' on amazon EC2 instance as under the hood Amazon uses Linux AMIs to run their Lambda functions.
2) copied the generated .so files and packaged inside the Lambda deployment package hope this will helps others as well who are searching for the solution.
Hope this will help you further, can you please share what you did to connect to MSSQL server using AWS Lambda.
Below is the folder structure of my lambda deployment package
Windows "pymssql" file not supported in AWS lambda since lambda running on Amazon Linux 2.
So we can get Linux-supported wheel files from the following official "pymssql" website download link. You look for "manylinux_2_24_x86_64" version file with the required python version. At the time of writing python 3.9 is the latest version. So download file will be "pymssql-2.2.2-cp39-cp39-manylinux_2_24_x86_64.whl".
Once download the wheel file execute the below command
pip install {path of downloaded wheel file} -t {target folder to store this package}
Example
pip install pymssql-2.2.2-cp39-cp39-manylinux_2_24_x86_64.whl -t /package
Finally i could do it. It didnt worked with windows packages so used ubuntu to package freetds.so file and it worked.
Along with pymssql try to import cypthon.
Just a quick update for new changes.
There seems to be some issue with python 3.9 AWS lambda, it throws the below error on pymssql==2.2.3.
{
"errorMessage": "Unable to import module 'index': No module named
'pymssql._pymssql'",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
but if I change the python version to 3.8, the error vanishes.

Categories

Resources