0

I'm supporting a lambda project (python 3.8) and when I run the command "sam local invoke LambdaFunction --event events/get_users.json", it gives the following error

`Invoking main.lambda_handler (python3.8)
arn:aws:lambda:sa-east-1:061977363137:layer:pyodbc-layer-3_8:1 is already cached. Skipping download
arn:aws:lambda:sa-east-1:061977363137:layer:my-api-libs:3 is already cached. Skipping download
Local image is up-to-date
Using local image: samcli/lambda-python:3.8-x86_64-25626f11905fabd722693f3a7.

Mounting C:\Projects\my-api\api-main\.aws-sam\build\LambdaFunction as /var/task:ro,delegated, inside runtime container
START RequestId: 71de187e-ce8d-4fb0-9ee1-58b5d578b330 Version: $LATEST
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
[ERROR] Runtime.ImportModuleError: Unable to import module 'main': cannot import name 'DEPRECATED_SERVICE_NAMES' from 'botocore.docs' (/opt/python/botocore/docs/__init__.py)
Traceback (most recent call last):
END RequestId: 3df868d8-6059-49c0-b401-e6d20754a442
REPORT RequestId: 3df868d8-6059-49c0-b401-e6d20754a442  Init Duration: 0.16 ms  Duration: 638.28 ms     Billed Duration: 639 ms Memory Size: 128 MB     Max Memory Used: 128 MB
{"errorMessage": "Unable to import module 'main': cannot import name 'DEPRECATED_SERVICE_NAMES' from 'botocore.docs' (/opt/python/botocore/docs/__init__.py)", "errorType": "Runtime.ImportModuleError", "stackTrace": []}`

boto3 and botocore are updated:

PS C:\Users\UserGuest\AppData\Local\Programs\Python\Python38> python.exe -m pip install --upgrade boto3
Requirement already satisfied: boto3 in c:\users\UserGuest\appdata\local\programs\python\python38\lib\site-packages (1.34.81)
Requirement already satisfied: botocore<1.35.0,>=1.34.81 in c:\users\UserGuest\appdata\local\programs\python\python38\lib\site-packages (from boto3) (1.34.81)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in c:\users\UserGuest\appdata\roaming\python\python38\site-packages (from boto3) (1.0.1)
Requirement already satisfied: s3transfer<0.11.0,>=0.10.0 in c:\users\UserGuest\appdata\local\programs\python\python38\lib\site-packages (from boto3) (0.10.1)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in c:\users\UserGuest\appdata\roaming\python\python38\site-packages (from botocore<1.35.0,>=1.34.81->boto3) (2.9.0.post0)
Requirement already satisfied: urllib3<1.27,>=1.25.4 in c:\users\UserGuest\appdata\roaming\python\python38\site-packages (from botocore<1.35.0,>=1.34.81->boto3) (1.26.18)
Requirement already satisfied: six>=1.5 in c:\users\UserGuest\appdata\roaming\python\python38\site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.35.0,>=1.34.81->boto3) (1.16.0)

But it's still showing the error I mentioned above.

Can anyone help me? Thanks!

2
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Mar 28, 2024 at 22:21
  • Same problem here. Tried using python 3.8, .9, .10, .11 and .12, but none works Commented Apr 17, 2024 at 10:49

1 Answer 1

0

I abandoned version 3.8 and updated to 3.12; Since then, I haven't had any more problems.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.