Python Pusher AWS Lambda

前端 未结 3 1681
生来不讨喜
生来不讨喜 2021-01-28 04:01

Using AWS Lambda to send push notifications to Pusher app in Python. When I install Pusher and all its dependencies to a directory and zip up to Lambda I run a simple test and g

相关标签:
3条回答
  • 2021-01-28 04:40

    This might sound silly, but don't name your local variable pusher. The binding of variables in the lambda function happens late, during its execution, and in a scope that you might not be expecting.

    I'm not suggesting this is the full answer, but do an import pusher and change to myPusher = pusher.Pusher... to see if the error message changes. If it doesn't, then the problem lies elsewhere.

    0 讨论(0)
  • 2021-01-28 04:47

    Adding an empty __init__.py file to the ndg directory fixed this issue.

    0 讨论(0)
  • 2021-01-28 04:54

    I would suggest you use virtualenv to keep track of dependencies.

    Here is a psedo steps that you may need to make:

     1. virtualenv env
     2. env/bin/pip install <your packages>
     3. cd env/lib/python2.7/site-packages; zip -r mylambda.zip *
     4. also zip your lambda handler 
    

    If you installed everything properly , then zip file mylambda.zip will contain everything you need.

    0 讨论(0)
提交回复
热议问题