Install & Compatibility
Where this runs
tested against v1.43.82 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 75.5MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 3.6s · import 0.000s · 25MB
49MB installed
● package 49MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
EC2Client
✓ from types_boto3_ec2 import EC2Client
✗ from types_boto3_ec2 import EC2Client
This quickstart demonstrates how types-boto3-ec2 provides type hints for your boto3 EC2 client, enabling static analysis and IDE autocompletion. The 'if TYPE_CHECKING:' block is optional but shows how to explicitly reference the stub types without creating a runtime dependency. The type checker will automatically infer types for `boto3.client('ec2')`.
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types_boto3_ec2 import EC2Client
# Boto3 client will be automatically typed by mypy-boto3-ec2 if installed
ec2_client: EC2Client = boto3.client('ec2')
# Example usage with type-hinted client
response = ec2_client.describe_instances(
Filters=[
{
'Name': 'instance-state-name',
'Values': ['running']
},
]
)
for reservation in response['Reservations']:
for instance in reservation['Instances']:
print(f"Instance ID: {instance['InstanceId']}, Type: {instance['InstanceType']}")
Debug
Known issues
breakingSupport for Python 3.8 was removed in mypy-boto3-builder 8.12.0 (and consequently for types-boto3-ec2 versions generated by it). Python 3.9+ is now required.fixUpgrade your Python environment to 3.9 or higher.
affects: mypy-boto3-builder >= 8.12.0
gotchaThis is a service-specific stub package. To get type annotations for other AWS services (e.g., S3, Lambda), you must install their respective `types-boto3-<service>` packages (e.g., `types-boto3-s3`). Installing just `types-boto3` will install a 'full' package but it's often more efficient to install specific stubs.fixInstall the specific stub package for each boto3 service you use (e.g., `pip install types-boto3-s3 types-boto3-lambda`).
affects: All versions
breakingIn mypy-boto3-builder 8.9.0, there were breaking changes to TypeDef naming conventions, where packed method arguments used shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `Extra` postfixes moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).fixUpdate your code to use the new TypeDef names if you were explicitly referencing them. Check the generated stub files or documentation for the correct new names.
affects: mypy-boto3-builder >= 8.9.0
gotchaThe `mypy-boto3` ecosystem switched to PEP 561 compliant packages in version 8.12.0. This primarily affects how type checkers locate and interpret the installed stub files.fixEnsure your type checker (e.g., mypy, pyright) is up-to-date and configured correctly to discover PEP 561 stub packages.
affects: mypy-boto3-builder >= 8.12.0
gotchaPylint might complain about undefined variables when using type hints with `types-boto3-ec2` outside of a `TYPE_CHECKING` block. It is recommended to use an `if TYPE_CHECKING:` guard and set types to `object` in the `else` branch to avoid runtime dependencies and Pylint warnings.fixWrap explicit type imports in `if TYPE_CHECKING:` blocks and provide fallback `object` assignments in the `else` block for runtime safety and Pylint compatibility, as shown in the quickstart example.
affects: All versions
Upgrade
Version history
1.43.82latest on PyPI · released Aug 27, 2026
Audit
Dependencies
boto3requiredThis package provides type stubs for the boto3 library, which must be installed to be used at runtime.