{"record":{"id":"398ec3f0289343ca","repo":"crewAIInc/crewAI","slug":"youtube-channel-support-requires-pytube-install-w","errorCode":null,"errorMessage":"YouTube channel support requires pytube. Install with: uv add pytube","messagePattern":"YouTube channel support requires pytube\\. Install with: uv add pytube","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py","lineNumber":29,"sourceCode":"    \"\"\"Loader for YouTube channels.\"\"\"\n\n    def load(self, source: SourceContent, **kwargs: Any) -> LoaderResult:  # type: ignore[override]\n        \"\"\"Load and extract content from a YouTube channel.\n\n        Args:\n            source: The source content containing the YouTube channel URL\n\n        Returns:\n            LoaderResult with channel content\n\n        Raises:\n            ImportError: If required YouTube libraries aren't installed\n            ValueError: If the URL is not a valid YouTube channel URL\n        \"\"\"\n        try:\n            from pytube import Channel  # type: ignore[import-untyped]\n        except ImportError as e:\n            raise ImportError(\n                \"YouTube channel support requires pytube. Install with: uv add pytube\"\n            ) from e\n\n        channel_url = source.source\n\n        if not any(\n            pattern in channel_url\n            for pattern in [\n                \"youtube.com/channel/\",\n                \"youtube.com/c/\",\n                \"youtube.com/@\",\n                \"youtube.com/user/\",\n            ]\n        ):\n            raise ValueError(f\"Invalid YouTube channel URL: {channel_url}\")\n\n        metadata: dict[str, Any] = {\n            \"source\": channel_url,","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py#L11-L47","documentation":"An ImportError raised by the YouTube channel loader when the optional dependency pytube is not installed in the environment. The import is deferred to load() time, so the failure only appears when a YouTube channel source is actually loaded, not at package import. The message tells you the exact install command for the uv workflow.","triggerScenarios":"Installing crewai-tools without the youtube extras, then calling youtube_channel_loader.load(...). Also triggered in environments where pytube was removed, or where a conflicting 'pytube' shadow package is installed.","commonSituations":"See trigger scenarios.","solutions":["Run: uv add pytube (or pip install pytube) in the same environment/venv that runs your application.","Verify with: python -c \"from pytube import Channel; print('ok')\".","If using a locked deployment (Docker, serverless), rebuild the image/layer after adding the dependency.","Check for a local file named pytube.py shadowing the real package."],"exampleFix":"# before\n# pytube missing -> ImportError at load()\nresult = yt_channel_loader.load(SourceContent(path=channel_url))\n\n# after (shell)\n# uv add pytube\nresult = yt_channel_loader.load(SourceContent(path=channel_url))","handlingStrategy":"validation","validationCode":"def pytube_available() -> bool:\n    try:\n        from pytube import Channel  # noqa: F401\n        return True\n    except ImportError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    result = yt_channel_loader.load(src)\nexcept ImportError as e:\n    if \"pytube\" in str(e):\n        raise ConfigError(\"install pytube to use YouTube channel sources\") from e\n    raise","preventionTips":["Declare YouTube extras in your own project's dependencies if you use these loaders.","Run a dependency availability check at app startup and disable YouTube sources when missing.","Pin optional deps in the same lockfile as everything else."],"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"}