错误 - Runtime.ImportModuleError:无法导入模块“main”:无法从“botocore.docs”导入名称“DEPRECATED_SERVICE_NAMES”

问题描述 投票:0回答:1

我支持 lambda 项目(python 3.8),当我运行命令“sam local invoke LambdaFunction --event events/get_users.json”时,它会给出以下错误

`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": []}`

boto3botocore 已更新:

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)

但它仍然显示我上面提到的错误。

有人可以帮助我吗? 谢谢!

python aws-lambda boto python-3.8 botocore
1个回答
0
投票

我放弃了3.8版本,更新到3.12;从那以后,我再也没有遇到过任何问题。

© www.soinside.com 2019 - 2024. All rights reserved.