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 get this error.
No module named ndg.httpsclient.ssl_peer_verification
Here is the code I'm trying to run.
from pusher import Pusher
pusher = Pusher(app_id=u'id', key=u'key', secret=u'secret')
def createPitchZip(context, event):
pusher.trigger('testchannel', 'testevent', {u'some': u'data'})
I've seen several posts about this but installing the dependencies individually doesn't seem to be helping.
Thanks!
Edit
Here is the stack trace
No module named ndg.httpsclient.ssl_peer_verification: ImportError
Traceback (most recent call last):
File "/var/task/lambda.py", line 5, in createPitchZip
pusher = Pusher(app_id='***', key='***', secret='***')
File "/var/task/pusher/pusher.py", line 42, in __init__
from pusher.requests import RequestsBackend
File "/var/task/pusher/requests.py", line 12, in <module>
import urllib3.contrib.pyopenssl
File "/var/task/urllib3/contrib/pyopenssl.py", line 49, in <module>
from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT
ImportError: No module named ndg.httpsclient.ssl_peer_verification
Adding an empty
__init__.py
file to thendg
directory fixed this issue.I would suggest you use
virtualenv
to keep track of dependencies.Here is a psedo steps that you may need to make:
If you installed everything properly , then zip file
mylambda.zip
will contain everything you need.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 tomyPusher = pusher.Pusher...
to see if the error message changes. If it doesn't, then the problem lies elsewhere.