Search code examples
pythonamazon-web-servicesaws-lambdaaws-xray

AWS Lambda and X-Ray: (Python) How To Install


TL;DR How do I install AWS X-Ray sdk, because the pip install doesn't seem to get the full package

Hello Folks,

I'm working on trying out AWS X-Ray for my Python lambda. I know the library is large, but I wanted to get a POC before putting it into a layer. The issue is that when I install it, it doesn't seem to get installed.

When I run pip install -r requirements.txt I see that it installs two packages, aws_xray_sdk and aws_xray_sdk-2.9.0.dist-info. When I look into these packages I see that they are 740 kilobytes altogether (makes me think this is a stub of some sort)

When I upload my lambda and test it, I get the following error even though the directories are in my venv:

[ERROR] Runtime.ImportModuleError: Unable to import module 'users/main': No module named 'aws_xray_sdk' Traceback (most recent call last):

Any help is greatly appreciated.


Solution

  • The issue was that I was not putting my dependencies in the root of my .zip file as the docs clearly show ='(

    4. Create a deployment package with the installed libraries at the root.