SimonH SimonH - 1 year ago 143
Python Question

Python 2.7 & emulambda

Just installed emulambda today, using the command:

pip install git+

and created a simple python file

from __future__ import print_function

def lambda_handler(event, context):
print("Hello world")

when I try and run this with the command

emulambda test.lambda_handler test-event.json

I get the errors

Oops! There was a problem finding your function.

Traceback (most recent call last):
File "/usr/local/bin/emulambda", line 5, in <module>
File "/usr/local/lib/python2.7/dist-packages/emulambda/", line 37, in main
lfunc = import_lambda(args.lambdapath)
File "/usr/local/lib/python2.7/dist-packages/emulambda/", line 121, in import_lambda
raise e
AttributeError: 'module' object has no attribute 'lambda_handler'

I'm running python 2.7.12 - can anyone suggest what the problem is?

Answer Source

You called your module, which is a conflict with the internal Python regression test module when you attempt to do the following:

emulambda test.lambda_handler test-event.json

Rename your file to something else like and try it again with:

emulambda simon_test.lambda_handler test-event.json
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download