简体   繁体   English

无法导入模块“lambda_function”:没有名为“orjson.orjson”的模块”,

[英]Unable to import module 'lambda_function': No module named 'orjson.orjson'",

I'm trying to run a Python Lambda function (which ran successfully in 3.6, and I'm now trying to upgrade to a supported version).我正在尝试运行 Python Lambda function(在 3.6 中成功运行,我现在正在尝试升级到受支持的版本)。 I'm getting this result:我得到这个结果:

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

The orjson library is presumably a dependency of one of my dependencies, as I'm not importing it directly. orjson 库可能是我的依赖项之一的依赖项,因为我没有直接导入它。 I have tried to include all necessary dependencies as a layer, and I have experimented with a variety of ways to structure the zip file with the dependencies installed, but this issue persists.我尝试将所有必要的依赖项包含为一个层,并且尝试了多种方法来构建安装了依赖项的 zip 文件,但这个问题仍然存在。

Is there anything I might be overlooking when creating the zip file for the layer?在为图层创建 zip 文件时,我可能会忽略什么吗?

I have been struggling with the same issue, and found out today that it is because orjson is built on my Mac while AWS Lambda uses Amazon Linux, making the orjson 's cpython artifact incompatible when deployed.我一直在为同样的问题而苦苦挣扎,今天发现这是因为orjson是在我的 Mac 上构建的,而 AWS Lambda 使用 Amazon Linux,这使得orjson的 cpython 工件在部署时不兼容。

Try using --use-container option when running sam build .运行sam build时尝试使用--use-container选项。 This builds the artifact on an Amazon Linux container, and has resolved the issue for me.这会在 Amazon Linux 容器上构建工件,并为我解决了这个问题。

Hope this helps.希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法导入模块“lambda_function”:没有名为“pymongo”的模块 - Unable to import module 'lambda_function': No module named 'pymongo' 无法导入模块“lambda_function”:没有名为“psycopg2._psycopg aws lambda 函数”的模块 - Unable to import module 'lambda_function': No module named 'psycopg2._psycopg aws lambda function AWS Lambda 层无法导入模块“lambda_function”:没有名为“pyarrow.lib”的模块 - AWS Lambda Layer Unable to import module 'lambda_function': No module named 'pyarrow.lib' 无法导入模块“lambda_function”: - Unable to import module 'lambda_function': 无法导入模块“lambda_function”:没有名为“flatten_json”的模块 - Unable to import module 'lambda_function': No module named 'flatten_json' 无法导入模块“lambda_function”:没有名为“aws_xray_sdk”的模块 - Unable to import module 'lambda_function': No module named 'aws_xray_sdk' 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 - 无法导入模块“lambda_function” - AWS Lambda - unable to import module 'lambda_function' Python 图层图像失败:“无法导入模块‘lambda_function’:无法从‘PIL’导入名称‘_imaging’” - Python Layer Image Failing: "Unable to import module 'lambda_function': cannot import name '_imaging' from 'PIL'"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM