crewAIInc/crewAI · error · ImportError

`boto3` package not found, please run `uv add boto3`

Error message

`boto3` package not found, please run `uv add boto3`

What it means

Raised inside BedrockKnowledgeBaseRetrievalTool._run() when the deferred `import boto3` (and botocore) fails, meaning the AWS SDK is not installed in the current environment. crewai-tools does not hard-depend on boto3; the Bedrock knowledge base tool imports it lazily and converts the ImportError into an actionable message including the uv add command.

Source

Thrown at lib/crewai-tools/src/crewai_tools/aws/bedrock/knowledge_base/retriever_tool.py:188

            result_object["score"] = result["score"]

        if "metadata" in result:
            result_object["metadata"] = result["metadata"]

        if "byteContent" in content_obj:
            result_object["byte_content"] = content_obj["byteContent"]

        if "row" in content_obj:
            result_object["row_content"] = content_obj["row"]

        return result_object

    def _run(self, query: str) -> str:
        try:
            import boto3
            from botocore.exceptions import ClientError
        except ImportError as e:
            raise ImportError(
                "`boto3` package not found, please run `uv add boto3`"
            ) from e

        try:
            # Initialize the Bedrock Agent Runtime client
            bedrock_agent_runtime = boto3.client(
                "bedrock-agent-runtime",
                region_name=os.getenv(
                    "AWS_REGION", os.getenv("AWS_DEFAULT_REGION", "us-east-1")
                ),
                # AWS SDK will automatically use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from environment
            )

            retrieve_params = {
                "knowledgeBaseId": self.knowledge_base_id,
                "retrievalQuery": {"text": query},
            }

View on GitHub (pinned to 754d7323be)

Solutions

  1. Run `uv add boto3` (or `pip install boto3`) in the same environment/venv the tool runs in
  2. For pip users: pip install crewai-tools[boto3] or just pip install boto3
  3. Verify with `python -c "import boto3"` using the same interpreter
  4. If it still fails, check for a mismatched virtualenv or PYTHONPATH shadowing

Example fix

# before: ImportError at tool run
# after (shell):
# uv add boto3
# python -c "import boto3; print(boto3.__version__)"
Defensive patterns

Strategy: validation

Validate before calling

try:
    import boto3  # noqa: F401
    from botocore.exceptions import ClientError  # noqa: F401
except ImportError:
    raise SystemExit('boto3 required for Bedrock KB tool: uv add boto3')

Try / catch

try:
    out = tool._run(q)
except ImportError as e:
    if 'boto3' in str(e):
        raise SystemExit('install boto3: uv add boto3') from e
    raise

Prevention

When it happens

Trigger: Calling the tool without boto3 installed: pip install crewai-tools alone, or a fresh uv venv missing the optional AWS extras; also a broken boto3 install where botocore is missing.

Common situations: Using the Bedrock tool for the first time after installing only crewai-tools; deploying to a slim Docker image without AWS dependencies; environment where boto3 was installed for a different Python interpreter.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/046cac7d25ab78fa. Report an issue: GitHub.