AWS Lambda Bigquery Storage Module Import Issue

0

Hi, I am facing following issue when I try to import Bigquey_storage module in Lambda.

"errorMessage": "Unable to import module 'lambda_function': cannot import name 'cygrpc' from 'grpc._cython' (/opt/python/grpc/_cython/__init__.py)",
  "errorType": "Runtime.ImportModuleError"

I have created the layer with the same Python runtime as in my lambda. I am using python 3.9 for my lambda and the layer. I tried installing grpcio module explicitly in the layer package. But it did not help.

Prior to this I created Google Cloud Big Query package, and it worked just fine.

Regards

asked a year ago471 views
2 Answers
0
Accepted Answer

After doing some research, it was suggested in a post to use the same OS to create the layer, that is used for lambda runtime. If you look at lambda runtimes, you can see that OS used in the runtimes is either Amazon Linux or Amazon Linux 2.

[https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html] (Lambda Runtimes).

So, I created a Virtual Machine with Amazon Linux 2 image and created the layer package on that machine. Now it works perfectly in the Lambda Function. I hope this helps.

answered a year ago
0

It seems like there is an issue with the grpc library in your Lambda function. Here are some steps you can try to resolve the issue:

  1. Make sure that you have installed the correct version of the grpc library that is compatible with Python 3.9. You can try upgrading to the latest version of the library to see if that resolves the issue.
  2. Check if you have added all the necessary dependencies to your Lambda layer. It is possible that you may be missing some dependencies that are required by the grpc library.
  3. Check if there are any conflicting dependencies between the grpc library and other libraries that you may have installed in your Lambda function. You can try removing all other libraries and see if the issue still persists.
  4. You can also try deploying your Lambda function with a newer version of the AWS Lambda runtime that may have better compatibility with the grpc library.
hash
answered a year 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