[Python] Invalid decimal literal (uuid.py, line 138) using Python 3.12 in AWS Lambda

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    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 :(

    Continue reading...

Compartilhe esta Página