課題: UbuntuにBoto3を入れたがエラーが出て動かない
結論:関連ライブラリを更新することで解消(多分)
以下が発生したエラー
>>> import boto3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.8/dist-packages/boto3/__init__.py", line 17, in <module> from boto3.session import Session File "/usr/local/lib/python3.8/dist-packages/boto3/session.py", line 17, in <module> import botocore.session File "/usr/local/lib/python3.8/dist-packages/botocore/session.py", line 26, in <module> import botocore.client File "/usr/local/lib/python3.8/dist-packages/botocore/client.py", line 18, in <module> from botocore.args import ClientArgsCreator File "/usr/local/lib/python3.8/dist-packages/botocore/args.py", line 27, in <module> from botocore.config import Config File "/usr/local/lib/python3.8/dist-packages/botocore/config.py", line 16, in <module> from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS File "/usr/local/lib/python3.8/dist-packages/botocore/endpoint.py", line 27, in <module> from botocore.httpchecksum import handle_checksum_body File "/usr/local/lib/python3.8/dist-packages/botocore/httpchecksum.py", line 36, in <module> from awscrt import checksums as crt_checksums ImportError: cannot import name 'checksums' from 'awscrt' (/usr/local/lib/python3.8/dist-packages/awscrt/__init__.py)
以下の手順で関連ライブラリを最新版に更新*1
sudo python -m pip install --upgrade awscrt sudo python -m pip install --upgrade awsiotsdk
エラーは解消
>>> import boto3 >>>
EC2 — Boto3 Docs 1.24.89 documentation
*1:root権限で入れるな、VirutalEnvを使えと怒られる(System Package Managerの矛盾を引き起こすリスク)ので、多分良くない操作と思う