3

I have a python3.6 script that uses sqlalchemy, pandas and numpy. To get this working on AWS Lambda, I took the following steps.

  1. Created a new, clean directory
  2. Create a new virtualenv
  3. Create a holding directory (mkdir dist)
  4. Install packages pip install sqlalchemy numpy pandas
  5. Navigate to packages cd env/lib/python3.6/site-packages
  6. Zip packages to holding directory zip -r path/dist/Transfer.zip .
  7. Navigate to root
  8. Zip python file zip -g dist/Transfer.zip my_python.py
  9. Upload to S3
  10. Direct Lambda > Configuration > Code entry type > Upload a file from S3 > path to my file
  11. Set Handler to my_python.lambda_handler
  12. 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.

gilch
  • 10,813
  • 1
  • 23
  • 28
ScottieB
  • 3,958
  • 6
  • 42
  • 60

0 Answers0