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
An ImportError raised in _run when `import boto3` (or botocore.exceptions) fails, meaning the AWS SDK is not installed in the current environment. The tool imports boto3 lazily at run time instead of install time, so the error surfaces only when the agent first invokes the tool.
Source
Thrown at lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py:97
raise BedrockValidationError("agent_id must be a string")
if not self.agent_alias_id:
raise BedrockValidationError("agent_alias_id cannot be empty")
if not isinstance(self.agent_alias_id, str):
raise BedrockValidationError("agent_alias_id must be a string")
if self.session_id and not isinstance(self.session_id, str):
raise BedrockValidationError("session_id must be a string")
except BedrockValidationError as e:
raise BedrockValidationError(f"Parameter validation failed: {e!s}") from e
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 = boto3.client(
"bedrock-agent-runtime",
region_name=os.getenv(
"AWS_REGION", os.getenv("AWS_DEFAULT_REGION", "us-west-2")
),
)
current_utc = datetime.now(timezone.utc)
prompt = f"""
The current time is: {current_utc}
Below is the users query or task. Complete it and answer it consicely and to the point:
{query}View on GitHub (pinned to 754d7323be)
Solutions
- Install the SDK: `uv add boto3` (message's own hint), or `pip install boto3`.
- Prefer the packaged extra if available so the dep is declared: `uv add 'crewai-tools[aws]'` / requirements pin boto3>=1.34.
- Verify before deploying: `python -c "import boto3; print(boto3.__version__)"`.
Example fix
# shell — before: ImportError # after uv add boto3 # or pin in pyproject.toml dependencies: "boto3>=1.34.0"
Defensive patterns
Strategy: validation
Validate before calling
try:
import boto3 # noqa
except ImportError:
raise SystemExit("boto3 missing — run `uv add boto3` before using Bedrock tools") Type guard
def boto3_available() -> bool:
try:
import boto3 # noqa: F401
return True
except ImportError:
return False Try / catch
try:
result = tool._run(query)
except ImportError as e:
if "boto3" in str(e):
raise SystemExit("Install boto3: uv add boto3") from e
raise Prevention
- Declare boto3 explicitly in your project dependencies; do not rely on the tool to prompt.
- Add a container/CI step that imports boto3 before running crews with AWS tools.
- Pin boto3>=1.34 (Bedrock Agents GA API surface).
When it happens
Trigger: Running the Bedrock agent tool in an environment where boto3 is absent — the try/except around `import boto3` / `from botocore.exceptions import ClientError` catches ImportError and re-raises with the install hint.
Common situations: Fresh virtualenv with only crewai-tools core deps; Docker images that trimmed AWS deps; team members who installed with `pip install crewai-tools` without the aws extra; CI runners caching an old env.
Related errors
- boto3 is required for Bedrock S3 file uploads. Install with:
- aioboto3 is required for async Bedrock S3 file uploads. Inst
- `boto3` package not found, please run `uv add boto3`
- `boto3` package not found, please run `uv add boto3`
- `boto3` package not found, please run `uv add boto3`
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/18fee9a8f18d6204.
Report an issue: GitHub.