aws / aws-iot-device-sdk-python-v2

Next generation AWS IoT Client SDK for Python using the AWS Common Runtime
Apache License 2.0
408 stars 213 forks source link

Packaging awsiot for AWS Lambda results in No module named '_awscrt' error. #140

Closed Shwetabh1 closed 3 years ago

Shwetabh1 commented 3 years ago

Confirm by changing [ ] to [x] below:

Platform/OS/Device What are you running the SDK on? I am running the SDK on AWS Lambda with a python version of 3.7.

Describe the question I am getting an import error that says `Failed to initialize Lambda runtime due to exception: No module named _awscrt. It is able to find the awscrt package but not the _awscrt. I have included both awsiot and awscrt to the zip bundle I have uploaded to create the lambda function.

Process of creating the zip file.

  1. Installed awsiot using pip3 locally on my mac(10.14).
  2. From the site packages copied awsiot and awscrt.
  3. Bundled them along with my code and uploaded them to AWS Lambda(Python3.7)
  4. While Testing I am getting No module named _awscrt
JonathanHenson commented 3 years ago

I suspect what happened was, you ran pip install on OS X, that pulled the wheel down from pypi for OS X. Then you packaged it and deployed it to lambda which is Linux, and while it sees the wheel you packaged, cannot load it.

you could try specifying platform when you run pip install or you could package from a Linux device. Could you try that and keep us posted?

In the meantime, we’ll work on improving this workflow for you.

Shwetabh1 commented 3 years ago

Packaging the dependencies from an ubuntu machine fixed the issue. Thanks.

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.