{"record":{"id":"846c6aad68e41e28","repo":"crewAIInc/crewAI","slug":"youtube-support-requires-youtube-transcript-api-i","errorCode":null,"errorMessage":"YouTube support requires youtube-transcript-api. Install with: uv add youtube-transcript-api","messagePattern":"YouTube support requires youtube-transcript-api\\. Install with: uv add youtube-transcript-api","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_video_loader.py","lineNumber":30,"sourceCode":"    \"\"\"Loader for YouTube videos.\"\"\"\n\n    def load(self, source: SourceContent, **kwargs: Any) -> LoaderResult:  # type: ignore[override]\n        \"\"\"Load and extract transcript from a YouTube video.\n\n        Args:\n            source: The source content containing the YouTube URL\n\n        Returns:\n            LoaderResult with transcript content\n\n        Raises:\n            ImportError: If required YouTube libraries aren't installed\n            ValueError: If the URL is not a valid YouTube video URL\n        \"\"\"\n        try:\n            from youtube_transcript_api import YouTubeTranscriptApi\n        except ImportError as e:\n            raise ImportError(\n                \"YouTube support requires youtube-transcript-api. \"\n                \"Install with: uv add youtube-transcript-api\"\n            ) from e\n\n        video_url = source.source\n        video_id = self._extract_video_id(video_url)\n\n        if not video_id:\n            raise ValueError(f\"Invalid YouTube URL: {video_url}\")\n\n        metadata: dict[str, Any] = {\n            \"source\": video_url,\n            \"video_id\": video_id,\n            \"data_type\": \"youtube_video\",\n        }\n\n        try:\n            api = YouTubeTranscriptApi()","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_video_loader.py#L12-L48","documentation":"ImportError raised by the YouTube video loader when the optional youtube-transcript-api package is missing. Like the channel loader, the import happens inside load(), so the error surfaces only when a YouTube video source is actually loaded. The message includes the exact uv add command.","triggerScenarios":"Calling youtube_video_loader.load(...) in an environment without youtube-transcript-api installed — base crewai-tools install without the YouTube extras, a fresh venv, or a Docker image that predates the dependency.","commonSituations":"Local dev works but CI/deployment fails because the extra was only installed ad hoc locally; multiple virtualenvs and the tool running under a different interpreter; dependency resolver removed the package after a conflict.","solutions":["Run: uv add youtube-transcript-api (or pip install youtube-transcript-api) in the executing environment.","Verify: python -c \"from youtube_transcript_api import YouTubeTranscriptApi; print('ok')\" using the same interpreter that runs your app.","Pin the dependency in pyproject/requirements so deployments install it automatically.","For channel loading you may also want pytube — the two YouTube loaders have separate optional deps."],"exampleFix":"# shell\n# before: package missing\n# after:\n# uv add youtube-transcript-api\nresult = yt_video_loader.load(SourceContent(path=\"https://www.youtube.com/watch?v=...\"))","handlingStrategy":"validation","validationCode":"def transcript_api_available() -> bool:\n    try:\n        from youtube_transcript_api import YouTubeTranscriptApi  # noqa: F401\n        return True\n    except ImportError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    result = yt_video_loader.load(src)\nexcept ImportError as e:\n    if \"youtube-transcript-api\" in str(e):\n        disable_youtube_sources()\n    raise","preventionTips":["Add youtube-transcript-api to your project's dependencies if you ingest video transcripts.","Check optional imports at startup and feature-flag YouTube ingestion accordingly.","Verify installs with the same interpreter that runs the app, not a different venv."],"tags":["youtube","dependency","import","optional-extra"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}