amazon-web-servicesaws-lambdapython-3.8aws-data-wrangler

AWS Lambda - AwsWrangler - Pandas/Pytz - Unable to import required dependencies:pytz:


To get past Numpy errors, I downloaded this zip awswrangler-layer-1.9.6-py3.8 from https://github.com/awslabs/aws-data-wrangler/releases.

I want to use Pandas to convert JSON to CSV and it's working fine in my PyCharm development environment on Windows 2000.

I have a script that builds the zip for my "deploy package" for Lambda. I create a new clean directory, copy my code in it, then copy the code from awsrangler into it.

At that point, I stopped getting the errors about Numpy version, and started getting the error below.

Error:

[ERROR] Runtime.ImportModuleError: Unable to import module 'AwsS3TriggerQuotesJsonToCsv': Unable to import required dependencies:pytz: No module named 'pytz'

What I don't understand is that pytz is in awsrangler and my distribution.

enter image description here

I'm using Python 3.8 on AWS, since that is higher version of wranger: awswrangler-layer-1.9.6-py3.8.

My first attempt I only included Pandas and Numpy modules. Second attempt was to also include the pytz module, same error. Third attempt, I included everything from awswrangler-layer-1.9.6-py3.8/python, even though I didn't need it all, but yet same error.


Solution

  • I updated my deploy script to delete the __pycache__ directory, and have got past this issue.

    Got the idea from this video about using Pandas on AWS Lambda: https://www.youtube.com/watch?v=vf1m1ogKYrg