I have a python3.6 script that uses sqlalchemy, pandas and numpy. To get this working on AWS Lambda, I took the following steps.
- Created a new, clean directory
- Create a new virtualenv
- Create a holding directory (
mkdir dist
) - Install packages
pip install sqlalchemy numpy pandas
- Navigate to packages
cd env/lib/python3.6/site-packages
- Zip packages to holding directory
zip -r path/dist/Transfer.zip .
- Navigate to root
- Zip python file
zip -g dist/Transfer.zip my_python.py
- Upload to S3
- Direct Lambda > Configuration > Code entry type > Upload a file from S3 > path to my file
- Set Handler to my_python.lambda_handler
- Save and test
I always get the error
{ "errorMessage": "Unable to import module 'my_python'" }
With the logs as
Unable to import module 'heap_consolidation_lambda': Missing required dependencies ['numpy']
Why can it not see numpy? Fwiw, numpy is the third import, so apparently it has no issues with sqlalchemy and pandas.