AWS Lambda Error (tesseract not installed)

Viewed 128

I have an issue about tesseract on my aws lambda. tesseract is working locally but not when i run the equivalent code in the lambda. The lambda works on python 3.7, tesseract is 0.3.7 (arn : arn:aws:lambda:eu-west-3:770693421928:layer:Klayers-python38-pytesseract:17).

I've installed the layers of tesseract and pillow.

text = pytesseract.image_to_string(Image.open('hello_world.png'), config=custom_config)

Here is the error I get:

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

Thank you so much for your help!

2 Answers

Image.open('hello_world.png') is from Pillow probably, so you need Pillow as well. Luckilly there is a public layer with it already:

arn:aws:lambda:eu-west-3:770693421928:layer:Klayers-python38-Pillow:10
Related