[英]AWS Lambda importError: Unable to import module 'lambda_function': No module named 'confluent_kafka.cimpl
I am trying to use confluent_kafka in my AWS Lambda function and I am adding a layer to it.我正在尝试在我的 AWS Lambda function 中使用 confluent_kafka 并向其添加一层。 The layer has a.zip file which contains following packages:
该层有一个 .zip 文件,其中包含以下包:
Note: All the above folders were created in the venv of pycharm when I ran the following command: pip install confluent_kafka, in the pycharm terminal.注意:以上所有文件夹都是在我运行以下命令时在pycharm的venv中创建的:pip install confluent_kafka,在pycharm终端。
I am getting an error:我收到一个错误:
{ "errorMessage": "Unable to import module 'lambda_function': No module named 'confluent_kafka.cimpl'", "errorType": "Runtime.ImportModuleError", "requestId": "3531b1f4-36b8-495a-a51f-f0e3105700b8", "stackTrace": [] } { “errorMessage”:“无法导入模块‘lambda_function’:没有名为‘confluent_kafka.cimpl’的模块”,“errorType”:“Runtime.ImportModuleError”,“requestId”:“3531b1f4-36b8-495a-a51f-f0e3105700b8”, “堆栈跟踪”: [] }
Please help me with solving this error.请帮我解决这个错误。
You have to zip with only one level of parent.您必须只有一级父级才能拨打 zip。 Try to extract the zip file and see if there are multiple folders(nested).
尝试提取 zip 文件并查看是否有多个文件夹(嵌套)。 for example if "layers" is your folder name then when you extract the zip file you should see the "layers" folder and all other libraries inside it and not another "layers" folder or so.
例如,如果“layers”是您的文件夹名称,那么当您提取 zip 文件时,您应该看到“layers”文件夹和其中的所有其他库,而不是另一个“layers”文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.