webptools icon indicating copy to clipboard operation
webptools copied to clipboard

UUID dependency issue with python 3 in AWS Lambda

Open TrafficScone opened this issue 3 years ago • 1 comments

Description Loading webptools in default AWS python 3.9 environment fails due to an error related to uuid:

{
  "errorMessage": "Syntax error in module 'lambda_function': invalid syntax (uuid.py, line 138)",
  "errorType": "Runtime.UserCodeSyntaxError",
  "requestId": "c644d245-fa99-456d-a8ad-edcad99a1bd9",
  "stackTrace": [
    "  File \"/var/task/uuid.py\" Line 138\n                if not 0 <= time_low < 1<<32L:\n"
  ]
}

Expected behavior Successful execution of simple script:

from webptools import cwebp

def lambda_handler(event, context):
    # Initialize variable from S3 event (ObjectCreated:Put)
    print('Initializing variables . . .')
    map_filename = event['Records'][0]['s3']['object']['key']
    map_name = map_filename.split('.')[0]

    print(map_name)
    return map_name

Steps to reproduce Try to load the package in an AWS Lambda environment

Steps to fix Believe this can be fixed if uuid is removed from setup.py since it is now included since the default uuid library is included in the python standard library (similar error)

TrafficScone avatar Jul 03 '22 18:07 TrafficScone

This have nothing to do with the lambda function, but its an error from your end.

You dont have to install the uuid package, and deploy in lambda.

If you are zipping and pushing to lambda (eg. via sls) then uninstall the uuid from local, or else if you are using docker images via ECR, remove the uuid from requirements.txt file.

Ref this StackOverflow answer: https://stackoverflow.com/questions/33612977/how-to-use-uuid-lib-with-mod-wsgi

HarshitRuwali avatar Feb 23 '23 12:02 HarshitRuwali