{"record":{"id":"691d21281a6cf487","repo":"unslothai/unsloth","slug":"s3-dataset-loading-requires-boto3-install-it-with","errorCode":null,"errorMessage":"S3 dataset loading requires boto3. Install it with: pip install boto3","messagePattern":"S3 dataset loading requires boto3\\. Install it with: pip install boto3","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/training/s3_dataset.py","lineNumber":162,"sourceCode":"    if cancel_callback is not None and cancel_callback():\n        raise S3DownloadCancelled(\"S3 dataset download cancelled\")\n\n\ndef prepare_s3_dataset_download(\n    s3_config: dict,\n    dest_dir: Optional[str] = None,\n    cancel_callback: Optional[Callable[[], bool]] = None,\n) -> S3DatasetDownload:\n    \"\"\"Download supported dataset files from S3 to a local directory.\n\n    Returns the local files plus the owned temporary directory, when one was\n    created. Call ``cleanup()`` after the dataset loader has materialized data.\n\n    Raises ``RuntimeError`` if boto3 is missing, and ``ValueError`` if the\n    bucket/prefix contains no supported dataset files.\n    \"\"\"\n    if not boto3_available():\n        raise RuntimeError(\"S3 dataset loading requires boto3. Install it with: pip install boto3\")\n\n    bucket = s3_config.get(\"bucket\")\n    if not bucket:\n        raise ValueError(\"s3_config.bucket is required\")\n    prefix = s3_config.get(\"prefix\")\n\n    _raise_if_cancelled(cancel_callback)\n    client = _build_s3_client(s3_config)\n\n    keys = _list_dataset_keys(client, bucket, prefix)\n    _raise_if_cancelled(cancel_callback)\n    if not keys:\n        where = f\"s3://{bucket}/{prefix}\" if prefix else f\"s3://{bucket}\"\n        raise ValueError(\n            f\"No supported dataset files ({', '.join(SUPPORTED_EXTENSIONS)}) \"\n            f\"found under {where}\"\n        )\n","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/training/s3_dataset.py#L144-L180","documentation":"RuntimeError raised at the top of prepare_s3_dataset_download when boto3_available() reports that the boto3 module cannot be imported. The S3 dataset loader needs boto3 at runtime but it is an optional dependency, so the environment check fails fast with an actionable install command instead of an ImportError deep in the download path.","triggerScenarios":"Calling prepare_s3_dataset_download in an environment where 'import boto3' fails — boto3 never installed, installed in a different virtualenv/interpreter than the one running the backend, or a broken install (missing botocore).","commonSituations":"Fresh deployment without the s3 extras; training container image built without boto3; IDE or systemd service using a different Python than the shell where boto3 was pip-installed.","solutions":["Install boto3 into the interpreter that runs the backend: pip install boto3 (match the exact venv/container).","Verify with the same interpreter: python -c \"import boto3\" from the service's environment.","Add boto3 to the deployment's dependency list (requirements/lockfile/image) so rebuilds keep it."],"exampleFix":"// before: module missing\n$ python -m pip list | grep -i boto3   # nothing\n// after\n$ python -m pip install boto3\n$ python -c \"import boto3; print(boto3.__version__)\"","handlingStrategy":"validation","validationCode":"import importlib.util\n\nassert importlib.util.find_spec('boto3') is not None, \\\n    \"boto3 missing — install it in this interpreter: pip install boto3\"","typeGuard":null,"tryCatchPattern":"try:\n    dl = prepare_s3_dataset_download(cfg)\nexcept RuntimeError as e:\n    if 'boto3' in str(e):\n        subprocess.run([sys.executable, '-m', 'pip', 'install', 'boto3'], check=True)\n        dl = prepare_s3_dataset_download(cfg)  # retry after install","preventionTips":["Include boto3 in the deployment's locked dependencies when S3 datasets are used.","Smoke-test `import boto3` in the service's virtualenv during deploy.","Use the same interpreter for pip and for running the backend."],"tags":["s3","dependencies","environment","dataset"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}