Just installed emulambda today, using the command:
pip install git+https://github.com/fugue/emulambda.git
and created a simple python file test.py:
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>
emulambda.main()
File "/usr/local/lib/python2.7/dist-packages/emulambda/__init__.py", line 37, in main
lfunc = import_lambda(args.lambdapath)
File "/usr/local/lib/python2.7/dist-packages/emulambda/__init__.py", 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?
You called your module test.py, 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 simon_test.py and try it again with:
emulambda simon_test.lambda_handler test-event.json
Related
I have a python script which I called via
pipenv run python3 script.py
Yesterday it worked fine, but today I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 7, in <module>
from pipenv import cli
File "/usr/local/lib/python2.7/dist-packages/pipenv/__init__.py", line 17,in <module>
from .cli import cli
File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 89, in <module>
if ((now.tm_mon == 10) and (now.tm_day == 30)) or ((now.tm_mon == 10) and (now.tm_day == 31)):
AttributeError: 'time.struct_time' object has no attribute 'tm_day'
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 7, in <module>
from pipenv import cli
File "/usr/local/lib/python2.7/dist-packages/pipenv/__init__.py", line 17, in <module>
I assume that it may have something to do with the new month starting, but I can't find a way to fix this (strange) problem.
Some further information:
The script runs on a raspberry pi. It uses the requests and the Adafruit_DHT library. I don't do any time-regarding operations in the python script by myself.
Could I kindly ask you to help me?
Many thanks in advance
Make on reinstall, direct repository latest version!
pip install git+https://github.com/kennethreitz/pipenv.git
Pretty sure this is a bug in pipenv. I've submitted an issue here
I have a project that I imported into pycharm. It looks like this:
The file grabber.py references class Fetcher within fetcher.py like this:
from grabber.fetcher import Fetcher
from the root folder Automaton I can run grabber.py from the command line with this command:
python -m grabber.grabber
But, I want to run grabber.py from pycharm. When I try I get this error:
Traceback (most recent call last):
File "C:/Automaton/grabber/grabber.py", line 1, in <module>
from grabber.fetcher import Fetcher
File "C:\Automaton\grabber\grabber.py", line 1, in <module>
from grabber.fetcher import Fetcher
ImportError: No module named 'grabber.fetcher'; 'grabber' is not a package
How do I get pycharm to run the file the same way I can from the command line?
My problem was pretty silly. I was having the problem because I had a package grabber and a file within it called grabber.py That name collision caused the problem. I renamed grabber.py and it works.
I am new to python and not knowing whats going on here. I have tried searching a lot but had to end up asking here
I am trying to learn subprocess which executes a simple command as:
import subprocess
subprocess.call(['ls'])
Now, when I run the program I get this error:
Traceback (most recent call last):
File "subprocess.py", line 1, in <module>
import subprocess
File "/task/subprocess.py", line 2, in <module>
subprocess.call(['ls'])
AttributeError: 'module' object has no attribute 'call'
You called your file subprocess.py, change then name and you will be ok. You are trying to import from your file and not the module
ldap-new:~ # rm -rf subprocess.pyc
This worked for me i just removed .pyc file and run again
Regards,
-Mansur
I'm trying to run a simple code to test that I have installed correctly pyexiv2 in my computer. I'm using python 2.6.6. on windows 7 64 bit
So I run this simple code:
import pyexiv2
print pyexiv2.exiv2_version_info
and I get this error:
Traceback (most recent call last):
File "C:/Users/Usuario/Desktop/pyexiv2/pyexiv2.py", line 1, in <module>
import pyexiv2
File "C:\Users\Usuario\Desktop\pyexiv2\pyexiv2.py", line 3, in <module>
print pyexiv2.version_info
AttributeError: 'module' object has no attribute 'version_info'
How can I fix that? Thank you
You named your own file pyexiv2.py as well; rename it or delete it, as it is being imported instead of the installed module.
Getting the following error when trying to run SPSS from an external Python IDE.
import spss
yields the following error
Traceback (most recent call last):
File "C:\Documents and Settings\USER\workspace\SPSS\src\NE ASQ 2010.py", line 6, in <module>
import spss
File "C:\Python26\Lib\site-packages\spss180\spss\spss.py", line 16, in <module>
error = errCode()
File "C:\Python26\Lib\site-packages\spss180\spss\errMsg.py", line 24, in __init__
self.errMsg = errTable['okay'][str(0)]
KeyError: 'okay'
Ran the Python essentials plug-in with no errors. Funny thing is that I dont get an error when I run this in a syntax
BEGIN PROGRAM PYTHON.
import spss
num = spss.GetVariableCount()
print num
END PROGRAM.
Any help will be much appreciated.
Brock
I believe I figured out the issue. I needed to configure Eclipse to see the external python modules that are created when you install the SPSS/Python plugin. I had to set a reference to the modules when configuring the project.
Once I did that, it looks like I am up and running!