{"id":719,"library":"types-awscrt","title":"Type Annotations for awscrt","description":"types-awscrt provides type annotations and code completion for the `awscrt` package, which offers Python 3 bindings for the AWS Common Runtime. It helps with static analysis and IDE support for `awscrt`'s native C libraries. The package version typically mirrors the `awscrt` version it provides types for. It is actively maintained as part of the `mypy_boto3_builder` project. [4, 7]","status":"active","version":"0.31.3","language":"python","source_language":"en","source_url":"https://github.com/youtype/types-awscrt","tags":["type-stubs","aws","awscrt","mypy","pyright"],"install":[{"cmd":"pip install types-awscrt","lang":"bash","label":"Install types-awscrt"}],"dependencies":[{"reason":"Required at runtime for the type stubs to be meaningful, as `types-awscrt` provides annotations for `awscrt`. The `awscrt` package itself requires Python >=3.8. [1, 8]","package":"awscrt","optional":true},{"reason":"Requires Python 3.8 or higher. [7, 8]","package":"Python","optional":false}],"imports":[{"symbol":"ClientBootstrap","correct":"from awscrt.io import ClientBootstrap"},{"symbol":"AwsCredentials","correct":"from awscrt.auth import AwsCredentials"},{"symbol":"S3Client","correct":"from awscrt.s3 import S3Client"},{"symbol":"EventLoopGroup","correct":"from awscrt.io import EventLoopGroup"}],"quickstart":{"code":"import os\nimport awscrt.io as io\nimport awscrt.auth as auth\nimport awscrt.s3 as s3 # Example usage\n\n# Initialize the AWS Common Runtime's I/O and event loop\n# types-awscrt provides type hints for these objects\nevent_loop_group: io.EventLoopGroup = io.EventLoopGroup()\nhost_resolver: io.DefaultHostResolver = io.DefaultHostResolver(event_loop_group)\nbootstrap: io.ClientBootstrap = io.ClientBootstrap(event_loop_group, host_resolver)\n\n# Example for AWS credentials (replace with actual logic, e.g., environment variables or assumed roles)\naccess_key_id = os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_ACCESS_KEY')\nsecret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET_KEY')\nsession_token = os.environ.get('AWS_SESSION_TOKEN', None) # Optional\n\ncredentials: auth.AwsCredentials = auth.AwsCredentials(\n    access_key_id=access_key_id,\n    secret_access_key=secret_access_key,\n    session_token=session_token\n)\n\nprint(f\"AWS CRT initialized. Credentials loaded (Access Key ID: {credentials.access_key_id}).\")\n# With types-awscrt installed, a type checker (like MyPy or Pyright) would validate the types above.","lang":"python","description":"This quickstart demonstrates basic initialization of `awscrt` components. `types-awscrt` enhances this experience by providing static type checking and IDE auto-completion for `awscrt` objects and methods."},"warnings":[{"fix":"Ensure `awscrt.io.init_logging()` is called only once in the application's lifecycle. Adjust tests to avoid re-initialization or reset logging state carefully if absolutely necessary.","message":"In `awscrt` versions 0.28.2 and later, `awscrt.io.init_logging()` can only be called once per process. Subsequent calls will raise an `AWS_ERROR_INVALID_STATE` exception. This can impact test suites or applications that attempt to re-initialize logging. [14]","severity":"breaking","affected_versions":"awscrt >= 0.28.2"},{"fix":"When using `multiprocessing`, explicitly set the start method to 'spawn' or 'forkserver' (e.g., `multiprocessing.set_start_method('spawn')`). If using `os.fork()` directly, ensure all CRT resources are released and all CRT threads are joined before forking. [8]","message":"`awscrt` uses background threads, which makes `os.fork()` unsafe on POSIX systems (excluding macOS) for Python versions 3.13 and earlier. Using `os.fork()` or the default `multiprocessing` start method ('fork') can lead to hangs or crashes in child processes. [8, 12]","severity":"gotcha","affected_versions":"awscrt all versions, Python < 3.14 on POSIX (excluding macOS)"},{"fix":"Be aware of this platform-specific behavior on macOS. If dynamic private key handling is critical, consider alternative approaches or ensure certificate-key pairs are managed appropriately within the Keychain.","message":"On macOS, once a private key is used with a certificate in `awscrt`, that certificate-key pair is imported into the Mac Keychain. All subsequent uses of that certificate will use the stored private key from the Keychain and will ignore any private key passed in programmatically. [1, 8, 12]","severity":"gotcha","affected_versions":"awscrt all versions on macOS"},{"fix":"Keep `types-awscrt` and `awscrt` versions synchronized as closely as possible to ensure accurate type checking. Refer to the `types-awscrt` changelog or GitHub releases for specific `awscrt` versions supported.","message":"`types-awscrt` aims to have its version mirror the `awscrt` version it provides type stubs for. Significant discrepancies between `types-awscrt` and `awscrt` versions can lead to incorrect type hints, missing definitions, or type-checking errors if the underlying `awscrt` API has changed without a corresponding `types-awscrt` update. [4, 7]","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the `awscrt` package is installed in the environment by running `pip install awscrt` or by including it in your project's `requirements.txt` and installing dependencies.","message":"The `awscrt` module could not be found, indicating that the `awscrt` package is not installed or not accessible in the current Python environment. This prevents any `awscrt` functionality from being used.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure `awscrt` is installed in the current Python environment using `pip install awscrt`. Verify that the Python interpreter being used has access to the installed package. Consider using a virtual environment (`python -m venv .venv` and `source .venv/bin/activate`) to manage dependencies and avoid conflicts with system-wide packages.","message":"The `awscrt` module was not found, indicating it is not installed in the current Python environment or is not accessible via the Python path. This error occurs when the Python interpreter cannot locate the package required by an `import` statement.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T18:15:35.571Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"import awscrt","cause":"`types-awscrt` is a type stub package for static analysis (e.g., mypy), not a runtime library, and should not be directly imported. The actual runtime library is `awscrt`.","error":"ModuleNotFoundError: No module named 'types_awscrt'"},{"fix":"pip install types-awscrt","cause":"The `awscrt` package itself does not include type annotations. `mypy` requires separate stub files, provided by `types-awscrt`, to perform type checking for `awscrt`.","error":"error: Library \"awscrt\" has no type annotations set up. [misc]"},{"fix":"from awscrt import io","cause":"Type stub packages like `types-awscrt` provide type hints for `awscrt` but are not meant for direct runtime import. You should import actual components from the `awscrt` package.","error":"ImportError: cannot import name 'io' from 'types_awscrt'"}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"0.31.3","install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.0M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.9M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.7M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.5M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.5M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}