[英]Unable to import module 'app': No module named 'app' in Aws Lambda using Chalice
I am having below lambda function which uses Chalice.我有以下 lambda function 使用圣杯。
from chalice import Chalice
from chalicelib import lookup_helper
import os
try:
from urllib import unquote
except ImportError:
from urllib.parse import unquote
app = Chalice(app_name='some_app')
@app.route('/some_route', methods=['GET'])
def some_func(arg):
//some code
When I test this function I get below error当我测试这个 function 时,出现以下错误
{"errorMessage": "Unable to import module 'app': No module named 'app'", "errorType": "Runtime.ImportModuleError"}
Tue Sep 22 11:59:10 UTC 2020 : Lambda execution failed with status 200 due to customer function error: Unable to import module 'app': No module named 'app'.
Can anyone please help me out here.谁能帮我解决这个问题。 Python - 3.7
Python - 3.7
Update--更新 -
from chalice import Chalice
import os
app = Chalice(app_name='some_app')
@app.route('/some_route', methods=['GET'])
def some_func(arg):
return {}
Reduced the function to above.将 function 减少到上面。 Still same error.
仍然是同样的错误。
When I checked the pipeline (azure devops), I see below error in the logs, though the step passes as a whole.当我检查管道 (azure devops) 时,我在日志中看到以下错误,尽管整个步骤都通过了。
FileExistsError: [Errno 17] File exists: 'build/lambda/requests'
requirement.txt需求.txt
requests==2.22.0
see https://chalice-workshop.readthedocs.io/en/latest/media-query/00-intro-chalice.html见https://chalice-workshop.readthedocs.io/en/latest/media-query/00-intro-chalice.html
Add a new function hello_world decorated by app.lambda_function() that returns {"hello": "world"}.
添加一个新的 function hello_world 由返回 {"hello": "world"} 的 app.lambda_function() 修饰。 Your app.py file should now consist of the following lines:
您的 app.py 文件现在应该包含以下几行:
from chalice import Chalice
app = Chalice(app_name='workshop-intro')
@app.lambda_function()
def hello_world(event, context):
return {'hello': 'world'}
What is the name of you python file.你的python文件叫什么名字。 Is it ' app.py '?
是“ app.py ”吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.