crewAIInc/crewAI · error · ImportError
YouTube channel support requires pytube. Install with: uv ad
Error message
YouTube channel support requires pytube. Install with: uv add pytube
What it means
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.
Source
Thrown at lib/crewai-tools/src/crewai_tools/rag/loaders/youtube_channel_loader.py:29
"""Loader for YouTube channels."""
def load(self, source: SourceContent, **kwargs: Any) -> LoaderResult: # type: ignore[override]
"""Load and extract content from a YouTube channel.
Args:
source: The source content containing the YouTube channel URL
Returns:
LoaderResult with channel content
Raises:
ImportError: If required YouTube libraries aren't installed
ValueError: If the URL is not a valid YouTube channel URL
"""
try:
from pytube import Channel # type: ignore[import-untyped]
except ImportError as e:
raise ImportError(
"YouTube channel support requires pytube. Install with: uv add pytube"
) from e
channel_url = source.source
if not any(
pattern in channel_url
for pattern in [
"youtube.com/channel/",
"youtube.com/c/",
"youtube.com/@",
"youtube.com/user/",
]
):
raise ValueError(f"Invalid YouTube channel URL: {channel_url}")
metadata: dict[str, Any] = {
"source": channel_url,View on GitHub (pinned to 754d7323be)
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.
Example fix
# before # pytube missing -> ImportError at load() result = yt_channel_loader.load(SourceContent(path=channel_url)) # after (shell) # uv add pytube result = yt_channel_loader.load(SourceContent(path=channel_url))
Defensive patterns
Strategy: validation
Validate before calling
def pytube_available() -> bool:
try:
from pytube import Channel # noqa: F401
return True
except ImportError:
return False Try / catch
try:
result = yt_channel_loader.load(src)
except ImportError as e:
if "pytube" in str(e):
raise ConfigError("install pytube to use YouTube channel sources") from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
Related errors
- YouTube support requires youtube-transcript-api. Install wit
- Unable to load YouTube channel {channel_url}: {e!s}
- The 'couchbase' package is required to use the CouchbaseFTSV
- `databricks-sdk` package not found, please run `uv add datab
- The 'daytona' package is required for Daytona sandbox tools.
AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15).
Data as JSON: /api/errors/398ec3f0289343ca.
Report an issue: GitHub.