1

I am following this instructions to create an AWS Lambda layer:

mkdir my-lambda-layer && cd my-lambda-layer
mkdir -p aws-layer/python/lib/python3.8/site-packages
pip3 install tweepy --target aws-layer/python/lib/python3.8/site-packages
cd aws-layer

I zip then the folder "python" (zip -r tweepy_layer.zip python/) and upload it to s3. This is what I see when I unzip the folder to double check:

enter image description here Unfortunately, I still get the following error though the pass should be the same as in the docs. I tried both from MacOs and Ubuntu though I do not think this should play a role for this particular library.

enter image description here

G. Macia
  • 1,204
  • 3
  • 23
  • 38

1 Answers1

1

Essentially the problem turned out to be the cache. Yes, all those __pycache__ and .pyc files. Thanks to this other question I cleared the cache after installing the libraries by doing

pip3 install pyclean
pyclean .

After cleaning the cache, re-doing the zip and uploading it to s3 the lambda setup works perfectly:

enter image description here

G. Macia
  • 1,204
  • 3
  • 23
  • 38