How to add mecab package in aws lambda?

165 views Asked by At
  • My goal is :

    create custom api on AWS-lambda which uses mecab to analyze the data.

  • Problem is:

    when i run test on aws-lambda it throws this kind of error.

    Execution result: failed(logs)
    {
      "errorMessage": "Unable to import module 'lambda_function': cannot import name '_MeCab' from 'MeCab' (/var/task/MeCab/__init__.py)",
      "errorType": "Runtime.ImportModuleError"
    } 
    
1

There are 1 answers

5
Avinash Dalvi On BEST ANSWER

There is two ways to use this library :

  1. Either create layer and upload library package folder there Then mapped this layer to lambda service
  2. Upload library package folder inside lambda package.

How to find library package folder : https://leemendelowitz.github.io/blog/how-does-python-find-packages.html

Layer documentation : https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html