我试图了解为什么我会收到此错误。
这些是我已经完成的步骤:
0)我在lambda_handler
脚本中创建了getUserInfo.py
函数
1)我创建了一个部署程序包,其getUserInfo.py
位于顶层
2)我更改了该目录中的权限:chmod -R 755 deployment_package
,导致:
3)我认为压缩了文件夹的内容并将其命名为getUserInfo.zip
4)然后我去在AWS中创建lambda函数,确保将handler
设置为getUserInfo.lambda_handler
5)当我运行并测试该函数时,似乎没有检测到我的getUserInfo.py
模块。
注意:这是在python 2.7中,并且我也尝试过包含__init.py__
,但效果不佳。有任何想法吗?
编辑:
这是getUserInfo.py
中的代码
from firebase import Firebase
def lambda_handler(event, context):
f = Firebase('https://unicon-1d994.firebaseio.com/Users')
return f.get()
Firebase
library是用于Firebase的REST API的包装。这是
unzip -l getUserInfo.zip
的输出Archive: getUserInfo.zip
Length Date Time Name
--------- ---------- ----- ----
0 03-08-2017 22:17 __init__.py
0 03-08-2017 22:17 __MACOSX/
546 03-08-2017 22:17 __MACOSX/.___init__.py
150 03-08-2017 21:18 getUserInfo.py
530 03-08-2017 21:18 __MACOSX/._getUserInfo.py
0 03-08-2017 20:16 requests/
2197 03-08-2017 20:16 requests/__init__.py
2964 03-08-2017 20:16 requests/__init__.pyc
1096 03-08-2017 20:16 requests/_internal_utils.py
1649 03-08-2017 20:16 requests/_internal_utils.pyc
19727 03-08-2017 20:16 requests/adapters.py
18990 03-08-2017 20:16 requests/adapters.pyc
5987 03-08-2017 20:16 requests/api.py
7158 03-08-2017 20:16 requests/api.pyc
9541 03-08-2017 20:16 requests/auth.py
10774 03-08-2017 20:16 requests/auth.pyc
348799 03-08-2017 20:16 requests/cacert.pem
625 03-08-2017 20:16 requests/certs.py
983 03-08-2017 20:16 requests/certs.pyc
1627 03-08-2017 20:16 requests/compat.py
1877 03-08-2017 20:16 requests/compat.pyc
18291 03-08-2017 20:16 requests/cookies.py
24424 03-08-2017 20:16 requests/cookies.pyc
2976 03-08-2017 20:16 requests/exceptions.py
7495 03-08-2017 20:16 requests/exceptions.pyc
767 03-08-2017 20:16 requests/hooks.py
1387 03-08-2017 20:16 requests/hooks.pyc
33067 03-08-2017 20:16 requests/models.py
29653 03-08-2017 20:16 requests/models.pyc
0 03-08-2017 20:16 requests/packages/
1384 03-08-2017 20:16 requests/packages/__init__.py
1677 03-08-2017 20:16 requests/packages/__init__.pyc
0 03-08-2017 20:16 requests/packages/chardet/
1295 03-08-2017 20:16 requests/packages/chardet/__init__.py
933 03-08-2017 20:16 requests/packages/chardet/__init__.pyc
82594 03-08-2017 20:16 requests/packages/chardet/big5freq.py
113848 03-08-2017 20:16 requests/packages/chardet/big5freq.pyc
1684 03-08-2017 20:16 requests/packages/chardet/big5prober.py
1364 03-08-2017 20:16 requests/packages/chardet/big5prober.pyc
2504 03-08-2017 20:16 requests/packages/chardet/chardetect.py
3175 03-08-2017 20:16 requests/packages/chardet/chardetect.pyc
9226 03-08-2017 20:16 requests/packages/chardet/chardistribution.py
9293 03-08-2017 20:16 requests/packages/chardet/chardistribution.pyc
3791 03-08-2017 20:16 requests/packages/chardet/charsetgroupprober.py
3016 03-08-2017 20:16 requests/packages/chardet/charsetgroupprober.pyc
1902 03-08-2017 20:16 requests/packages/chardet/charsetprober.py
2875 03-08-2017 20:16 requests/packages/chardet/charsetprober.pyc
2318 03-08-2017 20:16 requests/packages/chardet/codingstatemachine.py
2261 03-08-2017 20:16 requests/packages/chardet/codingstatemachine.pyc
1157 03-08-2017 20:16 requests/packages/chardet/compat.py
695 03-08-2017 20:16 requests/packages/chardet/compat.pyc
1335 03-08-2017 20:16 requests/packages/chardet/constants.py
400 03-08-2017 20:16 requests/packages/chardet/constants.pyc
1782 03-08-2017 20:16 requests/packages/chardet/cp949prober.py
1372 03-08-2017 20:16 requests/packages/chardet/cp949prober.pyc
3187 03-08-2017 20:16 requests/packages/chardet/escprober.py
2845 03-08-2017 20:16 requests/packages/chardet/escprober.pyc
7839 03-08-2017 20:16 requests/packages/chardet/escsm.py
7372 03-08-2017 20:16 requests/packages/chardet/escsm.pyc
3678 03-08-2017 20:16 requests/packages/chardet/eucjpprober.py
3254 03-08-2017 20:16 requests/packages/chardet/eucjpprober.pyc
45978 03-08-2017 20:16 requests/packages/chardet/euckrfreq.py
88839 03-08-2017 20:16 requests/packages/chardet/euckrfreq.pyc
1675 03-08-2017 20:16 requests/packages/chardet/euckrprober.py
1373 03-08-2017 20:16 requests/packages/chardet/euckrprober.pyc
34872 03-08-2017 20:16 requests/packages/chardet/euctwfreq.py
61237 03-08-2017 20:16 requests/packages/chardet/euctwfreq.pyc
1676 03-08-2017 20:16 requests/packages/chardet/euctwprober.py
1373 03-08-2017 20:16 requests/packages/chardet/euctwprober.pyc
36011 03-08-2017 20:16 requests/packages/chardet/gb2312freq.py
68855 03-08-2017 20:16 requests/packages/chardet/gb2312freq.pyc
1681 03-08-2017 20:16 requests/packages/chardet/gb2312prober.py
1380 03-08-2017 20:16 requests/packages/chardet/gb2312prober.pyc
13359 03-08-2017 20:16 requests/packages/chardet/hebrewprober.py
4084 03-08-2017 20:16 requests/packages/chardet/hebrewprober.pyc
47315 03-08-2017 20:16 requests/packages/chardet/jisfreq.py
84071 03-08-2017 20:16 requests/packages/chardet/jisfreq.pyc
19348 03-08-2017 20:16 requests/packages/chardet/jpcntx.py
26007 03-08-2017 20:16 requests/packages/chardet/jpcntx.pyc
12784 03-08-2017 20:16 requests/packages/chardet/langbulgarianmodel.py
24953 03-08-2017 20:16 requests/packages/chardet/langbulgarianmodel.pyc
17725 03-08-2017 20:16 requests/packages/chardet/langcyrillicmodel.py
30635 03-08-2017 20:16 requests/packages/chardet/langcyrillicmodel.pyc
12628 03-08-2017 20:16 requests/packages/chardet/langgreekmodel.py
24640 03-08-2017 20:16 requests/packages/chardet/langgreekmodel.pyc
11318 03-08-2017 20:16 requests/packages/chardet/langhebrewmodel.py
23460 03-08-2017 20:16 requests/packages/chardet/langhebrewmodel.pyc
12536 03-08-2017 20:16 requests/packages/chardet/langhungarianmodel.py
24937 03-08-2017 20:16 requests/packages/chardet/langhungarianmodel.pyc
11275 03-08-2017 20:16 requests/packages/chardet/langthaimodel.py
23446 03-08-2017 20:16 requests/packages/chardet/langthaimodel.pyc
5232 03-08-2017 20:16 requests/packages/chardet/latin1prober.py
3926 03-08-2017 20:16 requests/packages/chardet/latin1prober.pyc
3268 03-08-2017 20:16 requests/packages/chardet/mbcharsetprober.py
2888 03-08-2017 20:16 requests/packages/chardet/mbcharsetprober.pyc
1967 03-08-2017 20:16 requests/packages/chardet/mbcsgroupprober.py
1450 03-08-2017 20:16 requests/packages/chardet/mbcsgroupprober.pyc
19590 03-08-2017 20:16 requests/packages/chardet/mbcssm.py
17729 03-08-2017 20:16 requests/packages/chardet/mbcssm.pyc
4793 03-08-2017 20:16 requests/packages/chardet/sbcharsetprober.py
3773 03-08-2017 20:16 requests/packages/chardet/sbcharsetprober.pyc
3291 03-08-2017 20:16 requests/packages/chardet/sbcsgroupprober.py
2135 03-08-2017 20:16 requests/packages/chardet/sbcsgroupprober.pyc
3764 03-08-2017 20:16 requests/packages/chardet/sjisprober.py
3281 03-08-2017 20:16 requests/packages/chardet/sjisprober.pyc
6840 03-08-2017 20:16 requests/packages/chardet/universaldetector.py
4538 03-08-2017 20:16 requests/packages/chardet/universaldetector.pyc
2652 03-08-2017 20:16 requests/packages/chardet/utf8prober.py
2671 03-08-2017 20:16 requests/packages/chardet/utf8prober.pyc
0 03-08-2017 20:16 requests/packages/idna/
20 03-08-2017 20:16 requests/packages/idna/__init__.py
239 03-08-2017 20:16 requests/packages/idna/__init__.pyc
3299 03-08-2017 20:16 requests/packages/idna/codec.py
4585 03-08-2017 20:16 requests/packages/idna/codec.pyc
232 03-08-2017 20:16 requests/packages/idna/compat.py
1035 03-08-2017 20:16 requests/packages/idna/compat.pyc
11352 03-08-2017 20:16 requests/packages/idna/core.py
13018 03-08-2017 20:16 requests/packages/idna/core.pyc
35172 03-08-2017 20:16 requests/packages/idna/idnadata.py
38849 03-08-2017 20:16 requests/packages/idna/idnadata.pyc
1521 03-08-2017 20:16 requests/packages/idna/intranges.py
1890 03-08-2017 20:16 requests/packages/idna/intranges.pyc
184931 03-08-2017 20:16 requests/packages/idna/uts46data.py
277661 03-08-2017 20:16 requests/packages/idna/uts46data.pyc
0 03-08-2017 20:16 requests/packages/urllib3/
2853 03-08-2017 20:16 requests/packages/urllib3/__init__.py
3377 03-08-2017 20:16 requests/packages/urllib3/__init__.pyc
10553 03-08-2017 20:16 requests/packages/urllib3/_collections.py
15328 03-08-2017 20:16 requests/packages/urllib3/_collections.pyc
12709 03-08-2017 20:16 requests/packages/urllib3/connection.py
11768 03-08-2017 20:16 requests/packages/urllib3/connection.pyc
34940 03-08-2017 20:16 requests/packages/urllib3/connectionpool.py
28543 03-08-2017 20:16 requests/packages/urllib3/connectionpool.pyc
0 03-08-2017 20:16 requests/packages/urllib3/contrib/
0 03-08-2017 20:16 requests/packages/urllib3/contrib/__init__.py
215 03-08-2017 20:16 requests/packages/urllib3/contrib/__init__.pyc
10865 03-08-2017 20:16 requests/packages/urllib3/contrib/appengine.py
11388 03-08-2017 20:16 requests/packages/urllib3/contrib/appengine.pyc
4478 03-08-2017 20:16 requests/packages/urllib3/contrib/ntlmpool.py
4223 03-08-2017 20:16 requests/packages/urllib3/contrib/ntlmpool.pyc
15139 03-08-2017 20:16 requests/packages/urllib3/contrib/pyopenssl.py
19543 03-08-2017 20:16 requests/packages/urllib3/contrib/pyopenssl.pyc
6195 03-08-2017 20:16 requests/packages/urllib3/contrib/socks.py
6230 03-08-2017 20:16 requests/packages/urllib3/contrib/socks.pyc
6603 03-08-2017 20:16 requests/packages/urllib3/exceptions.py
15915 03-08-2017 20:16 requests/packages/urllib3/exceptions.pyc
5943 03-08-2017 20:16 requests/packages/urllib3/fields.py
7445 03-08-2017 20:16 requests/packages/urllib3/fields.pyc
2321 03-08-2017 20:16 requests/packages/urllib3/filepost.py
3719 03-08-2017 20:16 requests/packages/urllib3/filepost.pyc
0 03-08-2017 20:16 requests/packages/urllib3/packages/
109 03-08-2017 20:16 requests/packages/urllib3/packages/__init__.py
378 03-08-2017 20:16 requests/packages/urllib3/packages/__init__.pyc
0 03-08-2017 20:16 requests/packages/urllib3/packages/backports/
0 03-08-2017 20:16 requests/packages/urllib3/packages/backports/__init__.py
226 03-08-2017 20:16 requests/packages/urllib3/packages/backports/__init__.pyc
1461 03-08-2017 20:16 requests/packages/urllib3/packages/backports/makefile.py
1737 03-08-2017 20:16 requests/packages/urllib3/packages/backports/makefile.pyc
8935 03-08-2017 20:16 requests/packages/urllib3/packages/ordered_dict.py
11785 03-08-2017 20:16 requests/packages/urllib3/packages/ordered_dict.pyc
30098 03-08-2017 20:16 requests/packages/urllib3/packages/six.py
36813 03-08-2017 20:16 requests/packages/urllib3/packages/six.pyc
0 03-08-2017 20:16 requests/packages/urllib3/packages/ssl_match_hostname/
688 03-08-2017 20:16 requests/packages/urllib3/packages/ssl_match_hostname/__init__.py
676 03-08-2017 20:16 requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyc
5702 03-08-2017 20:16 requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py
4622 03-08-2017 20:16 requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyc
13053 03-08-2017 20:16 requests/packages/urllib3/poolmanager.py
13801 03-08-2017 20:16 requests/packages/urllib3/poolmanager.pyc
5946 03-08-2017 20:16 requests/packages/urllib3/request.py
6490 03-08-2017 20:16 requests/packages/urllib3/request.pyc
22662 03-08-2017 20:16 requests/packages/urllib3/response.py
21488 03-08-2017 20:16 requests/packages/urllib3/response.pyc
0 03-08-2017 20:16 requests/packages/urllib3/util/
994 03-08-2017 20:16 requests/packages/urllib3/util/__init__.py
1287 03-08-2017 20:16 requests/packages/urllib3/util/__init__.pyc
4237 03-08-2017 20:16 requests/packages/urllib3/util/connection.py
4207 03-08-2017 20:16 requests/packages/urllib3/util/connection.pyc
3704 03-08-2017 20:16 requests/packages/urllib3/util/request.py
3980 03-08-2017 20:16 requests/packages/urllib3/util/request.pyc
2343 03-08-2017 20:16 requests/packages/urllib3/util/response.py
2521 03-08-2017 20:16 requests/packages/urllib3/util/response.pyc
14123 03-08-2017 20:16 requests/packages/urllib3/util/retry.py
15048 03-08-2017 20:16 requests/packages/urllib3/util/retry.pyc
18836 03-08-2017 20:16 requests/packages/urllib3/util/selectors.py
22165 03-08-2017 20:16 requests/packages/urllib3/util/selectors.pyc
12046 03-08-2017 20:16 requests/packages/urllib3/util/ssl_.py
11184 03-08-2017 20:16 requests/packages/urllib3/util/ssl_.pyc
9757 03-08-2017 20:16 requests/packages/urllib3/util/timeout.py
10332 03-08-2017 20:16 requests/packages/urllib3/util/timeout.pyc
6289 03-08-2017 20:16 requests/packages/urllib3/util/url.py
6914 03-08-2017 20:16 requests/packages/urllib3/util/url.pyc
1451 03-08-2017 20:16 requests/packages/urllib3/util/wait.py
2066 03-08-2017 20:16 requests/packages/urllib3/util/wait.pyc
26216 03-08-2017 20:16 requests/sessions.py
22473 03-08-2017 20:16 requests/sessions.pyc
3316 03-08-2017 20:16 requests/status_codes.py
4649 03-08-2017 20:16 requests/status_codes.pyc
3012 03-08-2017 20:16 requests/structures.py
6141 03-08-2017 20:16 requests/structures.pyc
24827 03-08-2017 20:16 requests/utils.py
24866 03-08-2017 20:16 requests/utils.pyc
0 03-08-2017 20:16 requests-2.13.0.dist-info/
43228 03-08-2017 20:16 requests-2.13.0.dist-info/DESCRIPTION.rst
4 03-08-2017 20:16 requests-2.13.0.dist-info/INSTALLER
44453 03-08-2017 20:16 requests-2.13.0.dist-info/METADATA
1360 03-08-2017 20:16 requests-2.13.0.dist-info/metadata.json
13560 03-08-2017 20:16 requests-2.13.0.dist-info/RECORD
9 03-08-2017 20:16 requests-2.13.0.dist-info/top_level.txt
110 03-08-2017 20:16 requests-2.13.0.dist-info/WHEEL
0 03-08-2017 20:16 src/
185 03-08-2017 20:16 src/pip-delete-this-directory.txt
0 03-08-2017 20:16 src/python-firebase/
0 03-08-2017 20:16 src/python-firebase/.git/
0 03-08-2017 20:16 src/python-firebase/.git/branches/
319 03-08-2017 20:16 src/python-firebase/.git/config
73 03-08-2017 20:16 src/python-firebase/.git/description
23 03-08-2017 20:16 src/python-firebase/.git/HEAD
0 03-08-2017 20:16 src/python-firebase/.git/hooks/
478 03-08-2017 20:16 src/python-firebase/.git/hooks/applypatch-msg.sample
896 03-08-2017 20:16 src/python-firebase/.git/hooks/commit-msg.sample
189 03-08-2017 20:16 src/python-firebase/.git/hooks/post-update.sample
424 03-08-2017 20:16 src/python-firebase/.git/hooks/pre-applypatch.sample
1642 03-08-2017 20:16 src/python-firebase/.git/hooks/pre-commit.sample
1348 03-08-2017 20:16 src/python-firebase/.git/hooks/pre-push.sample
4951 03-08-2017 20:16 src/python-firebase/.git/hooks/pre-rebase.sample
544 03-08-2017 20:16 src/python-firebase/.git/hooks/pre-receive.sample
1239 03-08-2017 20:16 src/python-firebase/.git/hooks/prepare-commit-msg.sample
3610 03-08-2017 20:16 src/python-firebase/.git/hooks/update.sample
490 03-08-2017 20:16 src/python-firebase/.git/index
0 03-08-2017 20:16 src/python-firebase/.git/info/
240 03-08-2017 20:16 src/python-firebase/.git/info/exclude
0 03-08-2017 20:16 src/python-firebase/.git/logs/
198 03-08-2017 20:16 src/python-firebase/.git/logs/HEAD
0 03-08-2017 20:16 src/python-firebase/.git/logs/refs/
0 03-08-2017 20:16 src/python-firebase/.git/logs/refs/heads/
198 03-08-2017 20:16 src/python-firebase/.git/logs/refs/heads/master
0 03-08-2017 20:16 src/python-firebase/.git/logs/refs/remotes/
0 03-08-2017 20:16 src/python-firebase/.git/logs/refs/remotes/origin/
198 03-08-2017 20:16 src/python-firebase/.git/logs/refs/remotes/origin/HEAD
0 03-08-2017 20:16 src/python-firebase/.git/objects/
0 03-08-2017 20:16 src/python-firebase/.git/objects/info/
0 03-08-2017 20:16 src/python-firebase/.git/objects/pack/
2752 03-08-2017 20:16 src/python-firebase/.git/objects/pack/pack-e76e0e23b3d405b43031afd8eb87481de99b3eb5.idx
9436 03-08-2017 20:16 src/python-firebase/.git/objects/pack/pack-e76e0e23b3d405b43031afd8eb87481de99b3eb5.pack
252 03-08-2017 20:16 src/python-firebase/.git/packed-refs
0 03-08-2017 20:16 src/python-firebase/.git/refs/
0 03-08-2017 20:16 src/python-firebase/.git/refs/heads/
41 03-08-2017 20:16 src/python-firebase/.git/refs/heads/master
0 03-08-2017 20:16 src/python-firebase/.git/refs/remotes/
0 03-08-2017 20:16 src/python-firebase/.git/refs/remotes/origin/
32 03-08-2017 20:16 src/python-firebase/.git/refs/remotes/origin/HEAD
0 03-08-2017 20:16 src/python-firebase/.git/refs/tags/
39 03-08-2017 20:16 src/python-firebase/.gitignore
0 03-08-2017 20:16 src/python-firebase/firebase/
2504 03-08-2017 20:16 src/python-firebase/firebase/__init__.py
0 03-08-2017 20:16 src/python-firebase/python_firebase.egg-info/
1 03-08-2017 20:16 src/python-firebase/python_firebase.egg-info/dependency_links.txt
376 03-08-2017 20:16 src/python-firebase/python_firebase.egg-info/PKG-INFO
25 03-08-2017 20:16 src/python-firebase/python_firebase.egg-info/requires.txt
214 03-08-2017 20:16 src/python-firebase/python_firebase.egg-info/SOURCES.txt
9 03-08-2017 20:16 src/python-firebase/python_firebase.egg-info/top_level.txt
1744 03-08-2017 20:16 src/python-firebase/README.md
25 03-08-2017 20:16 src/python-firebase/requirements.txt
510 03-08-2017 20:16 src/python-firebase/setup.py
--------- -------
3104275 265 files
最佳答案
嗨,我终于解决了。原来这是给我的错误,因为它无法导入Firebase
依赖项,因为Firebase
位于一个名为src
的文件夹中。
关于Python:AWS Lambda "errorMessage": "Unable to import module ' <module_name >'",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42669904/