【问题标题】:Python not able to find modulesPython无法找到模块
【发布时间】:2020-08-06 17:30:56
【问题描述】:

我有一个 lambda 函数,我在其中使用 aws_lambda_powertools。 Lambda 函数项目结构如下-

source->Folder
   - handler.py
libs
   - aws-lambda-powertools
   - aws-xray-sdk
   - other libs which aws-lambda-powertools need

handler.py
from libs.aws_lambda_powertools import Logger, Tracer

当我运行 lambda 时,它给我一个错误“没有找到模块 aws_xray_sdk”,即使模块(由 aws-powertools 使用)在 libs 文件夹下。

我在 lambda 中使用的 Tracer 的来源。 https://github.com/awslabs/aws-lambda-powertools-python/blob/f5d14e3279276192c6fed0907b84b1dfa23c7b3c/aws_lambda_powertools/tracing/tracer.py

【问题讨论】:

  • 找不到哪个模块?你能发布完整的堆栈吗?
  • 添加模块名称
  • 可能你的 Python 路径搞砸了。 $ which python
  • Python 3.6 版

标签: python aws-lambda python-3.6 aws-xray


【解决方案1】:

听起来 Python 不知道去哪里找。一个想法是将 __init__.py 文件放在您的目录中,以便 Python 知道这些是包

【讨论】:

【解决方案2】:

您是否在 lambda 环境变量中定义 LD_LIBRARY_PATH?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-27
    • 2017-08-21
    • 2011-10-24
    • 1970-01-01
    • 2020-12-03
    • 2023-02-07
    • 2021-10-16
    • 2022-12-13
    相关资源
    最近更新 更多