Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pythob-based Azure function cannot load UUID package? [duplicate]

I'm trying to generate a token with uuid in lambda with Python 3.12 runtime. I installed last uuid in my local venv with Python 3.12 and use it as lamdba layer, but have the problem:

[ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'lambda_function': invalid decimal literal (uuid.py, line 138)
Traceback (most recent call last):
  File "/opt/python/lib/python3.12/site-packages/uuid.py" Line 138
                if not 0 <= time_low < 1<<32L:

Here is my code:

import uuid

def lambda_handler(event, context):
.
.
.
if response.status_code == 200:
            tokens = response.json()
            print("Token de acceso obtenido de Spotify: ", tokens['access_token'])
            session_token = str(uuid.uuid4())
            try:
                response = table.put_item(
                Item={
                    'session_token': session_token,
                    'access_token': tokens['access_token'],
                    'refresh_token': tokens['refresh_token'],
                    # Puedes guardar tambiΓ©n otros datos como 'expires_in', 'scope', etc.
                    }
                )

Is not a problem of lambda layers because all libraries are importing ok, also install the last version on uuid with pip, so I don't know what the problem is :(

like image 414
Michelle Luna Alama Avatar asked Jan 27 '26 14:01

Michelle Luna Alama


1 Answers

I just delete uuid library from the Lambda Layer, so it seems that by default Python3.12 have uuid in AWS Lambda πŸ˜…πŸ˜…πŸ˜…πŸ˜…

like image 128
Michelle Luna Alama Avatar answered Jan 29 '26 04:01

Michelle Luna Alama