【发布时间】:2019-05-18 02:19:29
【问题描述】:
应用结构:
.
├── Makefile
├── Pipfile
├── Pipfile.lock
├── README.md
├── template.yaml
├── tests
│ ├── __init__.py
│ └── unit
│ └── lambda_application
│ ├── test_handler.py
│ └── test_parent_child_class.py
└── lambda_application
├── __init__.py
├── first_child_class.py
├── lambda_function.py
├── second_child_class.py
├── requirements.txt
└── parent_class.py
4 directories, 14 files
来自lambda_function.py的代码示例:
import os
import json
from hashlib import sha256
import boto3
from requests import Session
from .first_child_class import FirstChildClass
def lambda_handler(event, context):
# Do some stuff.
按原样,我收到错误消息“无法导入模块 'lambda_function'”,但如果我注释掉最后一个导入“from .first_child_class import FirstChildClass”,它能够通过该部分并得到错误我还没有为那个类加载模块。
当我在 lambci/lambda:python3.7 docker 映像中运行它以及在 AWS 上部署时,我似乎只会收到此错误。我所有的测试都通过了,它能够毫无问题地导入模块。
我应该在__init__.py 文件中加载/设置什么吗?
编辑我更改了一些文件的名称以将其发布在此处。
【问题讨论】:
标签: python python-3.x amazon-web-services aws-lambda