Skip to content

Instantly share code, notes, and snippets.

@sohang3112
Last active April 29, 2024 12:55
Show Gist options
  • Save sohang3112/4b81443577c7cae36266aba6699c3c17 to your computer and use it in GitHub Desktop.
Save sohang3112/4b81443577c7cae36266aba6699c3c17 to your computer and use it in GitHub Desktop.

Creating AWS Lambda Layer for wordcloud Python library

wordcloud depends on matplotlib and numpy

Steps adapted from how to create AWS Lambda Layer for Python.

Note: Ran all the below steps in an EC2 Linux server.

  • mk wordcloud_layer && cd wordcloud_layer
  • Create requirements.txt:
wordcloud>=1.9.3
pillow>=9.5
  • Pip install like this:
$ mkdir python
$ pip install \
--no-cache-dir \
--platform manylinux2014_x86_64 \
--target=python/ \
--implementation cp \
--python-version 3.11 \
--only-binary=:all: \
--upgrade \
-r requirements.txt
  • Create a layer zip: zip -r9 wordcloud-layer.zip .
  • Upload zip to S3: aws s3 cp wordcloud-layer.zip s3://bucket/path/to/folder/wordcloud-layer.zip
  • Now create an AWS Lambda Layer from AWS Console using the above S3 URI of the layer zip, specifying runtime Python 3.11 and architecture x86.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment