-
Install pandas to local directory with pip:
pip install -t . pandas -
Remove pandas and numpy directories
rm -r pandas numpy -
Download the Linux distribution for pandas (choose the Python version that you want to use): https://pypi.org/project/pandas/#files
-
Download the Linux distribution for numpy (must be the same as the pandas one): https://pypi.org/project/numpy/#files
-
Move the downloaded files to your current directory and unzip them:
unzip numpy-1.16.1-cp36-cp36m-manylinux1_x86_64.whlandunzip pandas-0.24.1-cp36-cp36m-manylinux1_x86_64.whla. Note: Lambda with Python 3.7 requires pytz lib:
$ pip install -t . pytz -
Remove unecessary files:
rm -r *.whl *.dist-info __pycache__ -
Make the following directory (change the version of Python according to what you downloaded earlier):
lambda_layers/python/lib/python3.8/site-packages/. -
Move your whole directory into the
site-packagesfolder. -
Go to
cd lambda_layersand run:zip -r pandas_lambda_layer.zip * -
Upload the zip to S3.
-
Create a Layer that uses the file uploaded to S3.
-
Create a Lambda function (must uses the same Python version than before).
-
You can test that everything works by using the code in
lambda_function.py -
Have fun with pandas!
Sources:
After a few tried, I got this error
Is it expected?