简体   繁体   English

无法导入模块“app”:使用 Chalice 在 Aws Lambda 中没有名为“app”的模块

[英]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.htmlhttps://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.

相关问题 AWS Lambda 导入 psycopg2 - 无法导入模块“app”:没有名为“psycopg2._psycopg”的模块 - AWS Lambda Importing psycopg2 - Unable to import module 'app': No module named 'psycopg2._psycopg AWS SAM Lambda - 无法导入模块“main”:没有名为“requests”、“msal”的模块。 使用 Azure CI/CD 的管道 - AWS SAM Lambda - Unable to import module 'main': No module named 'requests', 'msal' . pipeline using Azure CI/CD AWS Lambda 层无法导入模块“lambda_function”:没有名为“pyarrow.lib”的模块 - AWS Lambda Layer Unable to import module 'lambda_function': No module named 'pyarrow.lib' 无法导入模块“lambda_function”:没有名为“psycopg2._psycopg aws lambda 函数”的模块 - Unable to import module 'lambda_function': No module named 'psycopg2._psycopg aws lambda function aws lambda 无法导入模块“lambda_function”:没有名为“requests”的模块 - aws lambda Unable to import module 'lambda_function': No module named 'requests' AWS Lambda 导入错误:无法导入模块“lambda_function”:没有名为“confluent_kafka.cimpl”的模块 - AWS Lambda importError: Unable to import module 'lambda_function': No module named 'confluent_kafka.cimpl AWS Lambda Chalice 应用程序未收到请求负载 - AWS Lambda Chalice app not receiving request payload 无法导入模块“lambda_function”:没有名为“aws_xray_sdk”的模块 - Unable to import module 'lambda_function': No module named 'aws_xray_sdk' 无法导入模块“lambda_function”:没有名为“pymongo”的模块 - Unable to import module 'lambda_function': No module named 'pymongo' "errorMessage": "无法导入模块 'app': 没有名为 'app' 的模块", "errorType": "Runtime.ImportModuleError", - "errorMessage": "Unable to import module 'app': No module named 'app'", "errorType": "Runtime.ImportModuleError",
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM