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
Identical lazy-import guard to the reader, but in S3WriterTool._run(): when boto3 is not importable at write time, the ImportError is re-raised with the message telling the user to run `uv add boto3`. Note the S3 tools also rely on CREW_AWS_* env vars for credentials, which is a separate concern after this error is resolved.
Source
Thrown at lib/crewai-tools/src/crewai_tools/aws/s3/writer_tool.py:27
file_path: str = Field(
..., description="S3 file path (e.g., 's3://bucket-name/file-name')"
)
content: str = Field(..., description="Content to write to the file")
class S3WriterTool(BaseTool):
name: str = "S3 Writer Tool"
description: str = "Writes content to a file in Amazon S3 given an S3 file path"
args_schema: type[BaseModel] = S3WriterToolInput
package_dependencies: list[str] = Field(default_factory=lambda: ["boto3"])
def _run(self, file_path: str, content: 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:
bucket_name, object_key = self._parse_s3_path(file_path)
s3 = boto3.client(
"s3",
region_name=os.getenv("CREW_AWS_REGION", "us-east-1"),
aws_access_key_id=os.getenv("CREW_AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.getenv("CREW_AWS_SEC_ACCESS_KEY"),
)
s3.put_object(
Bucket=bucket_name, Key=object_key, Body=content.encode("utf-8")
)
return f"Successfully wrote content to {file_path}"
except ClientError as e:View on GitHub (pinned to 754d7323be)
Solutions
- Install boto3 in the running environment (uv add boto3 / pip install boto3)
- Smoke-test tool availability at app startup: try import boto3 and fail fast with a clear message
- Pin boto3 in the project's dependency file so deployments include it
Example fix
# before: S3WriterTool()._run('s3://b/k', 'data') raises ImportError
# after (startup check):
try:
import boto3 # noqa: F401
except ImportError:
raise SystemExit('boto3 required for S3 tools: run `uv add boto3`') Defensive patterns
Strategy: validation
Validate before calling
try:
import boto3 # noqa: F401
except ImportError:
raise SystemExit('S3WriterTool needs boto3: run `uv add boto3`') Try / catch
try:
S3WriterTool()._run('s3://bucket/key', 'data')
except ImportError as e:
if 'boto3' in str(e):
logger.error('missing dependency: uv add boto3')
raise Prevention
- Declare boto3 explicitly even though the tool only hints at it via package_dependencies
- Smoke-test optional tool dependencies at app startup
- Keep write-path and read-path dependency checks identical so failures surface early
When it happens
Trigger: Calling S3WriterTool._run(file_path, content) in an environment lacking boto3 — e.g. agent writes to S3 only late in a run, so the dependency gap surfaces at write time rather than at startup.
Common situations: Agent pipelines where S3 write is an optional branch; production images built without AWS deps; notebook environments where the tool was never exercised before deploy.
Related errors
- `boto3` package not found, please run `uv add boto3`
- boto3 is required for Bedrock S3 file uploads. Install with:
- `boto3` package not found, please run `uv add boto3`
- aioboto3 is required for async Bedrock S3 file uploads. Inst
- `boto3` package not found, please run `uv add boto3`
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/2ac6bb40d0501a7d.
Report an issue: GitHub.