I am new to Python and looking for some kind of help. Python Lambda function below is throwing me expected error.
Unable to import module 'lambda_function': No module named 'stomp'
Python Lambda Script:-
import time
import boto3
import stomp
kinesis_client = boto3.client('kinesis')
class Listener(stomp.ConnectionListener):
def on_error(self, headers, message):
print('received an error "%s"' % message)
def on_message(self, headers, message):
print('received a message "%s"' % message)
kinesis_client.put_record(
StreamName='inter-lambda',
Data=u'{}\r\n'.format(message).encode('utf-8'),
PartitionKey='0'
)
I use mac to execute command and below is the error:-
sudo pip install stompy -t /Users/kalyanbhave/Documents/stomp/
Password:
The directory '/Users/kalyanbhave/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/kalyanbhave/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting stompy
Downloading https://files.pythonhosted.org/packages/af/21/8f3bdf1f304ba65847706c29d1950525513ec11d941ed0630ee8af51b361/stompy-0.2.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-install-rgmh5da6/stompy/setup.py", line 2, in <module>
from stompy import distmeta
File "/private/tmp/pip-install-rgmh5da6/stompy/stompy/__init__.py", line 1, in <module>
from stompy.stomp import Stomp, NotConnectedError
File "/private/tmp/pip-install-rgmh5da6/stompy/stompy/stomp.py", line 49
except socket.timeout, exc:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-rgmh5da6/stompy/