Lambda 函数:“无法导入模块‘lambda_function’:没有名为‘utils’的模块”

问题描述 投票:0回答:1

我一直在尝试将 Docker 镜像上传到 AWS Lambda Function, 我在 Lambda 函数中的导入如下所示:

...
from utils.textarct_ocr_facturas import Textract
from utils.clasificador_doc import clasificadorDoc2S3
from utils.sendDatabase import postgreSQLDatabase
from utils.openai_qr import OpenAIStrucured
...

我的文件夹是这样的:

Lambda (folder)
 |_lambda_function.py
 |_Dockerfile
 |_requirements.txt
 |__init_.py
 |_utils (folder)
   |_textarct_ocr_facturas.py
   |_clasificador_doc.py
   |_sendDatabase.py
   |_openai_qr.py

错误是这样的:

{
  "errorMessage": "Unable to import module 'lambda_function': No module named 'utils'",
  "errorType": "Runtime.ImportModuleError",
  "stackTrace": []
}

我尝试使用“.utils ....”导入,但错误是相同的。

我不知道这些模块发生了什么。

请帮忙。

谢谢。

python python-3.x amazon-web-services aws-lambda module
1个回答
0
投票

__init_.py
应在
utils/
文件夹中创建。否则,
utils
不被视为模块。

© www.soinside.com 2019 - 2024. All rights reserved.