crewAIInc/crewAI · error · Exception

crewai is not in the dependencies.

Error message

crewai is not in the dependencies.

What it means

Internal guard in _get_project_attribute: after parsing pyproject.toml, it verifies some entry in [project].dependencies contains the substring 'crewai'. If none does, it raises this generic Exception, which is then caught by the broad handler and printed as 'Error reading the pyproject.toml file: crewai is not in the dependencies.' It exists to prevent these helpers from running outside a real crewai project.

Source

Thrown at lib/crewai-core/src/crewai_core/project.py:176

) -> Any | None:
    """Look up a dotted attribute path inside ``pyproject_path``.

    The file must declare ``crewai`` in ``[project].dependencies`` for the
    lookup to succeed (a guard against running these helpers outside a crewai
    project directory). When ``require=True``, missing attributes raise
    ``SystemExit`` after printing a friendly error.
    """
    attribute = None

    try:
        with open(pyproject_path, "r") as f:
            pyproject_content = parse_toml(f.read())

        dependencies = (
            _get_nested_value(pyproject_content, ["project", "dependencies"]) or []
        )
        if not any(True for dep in dependencies if "crewai" in dep):
            raise Exception("crewai is not in the dependencies.")

        attribute = _get_nested_value(pyproject_content, keys)
    except FileNotFoundError:
        console.print(f"Error: {pyproject_path} not found.", style="bold red")
    except KeyError:
        console.print(
            f"Error: {pyproject_path} is not a valid pyproject.toml file.",
            style="bold red",
        )
    except Exception as e:
        if sys.version_info >= (3, 11) and isinstance(e, tomllib.TOMLDecodeError):
            console.print(
                f"Error: {pyproject_path} is not a valid TOML file.", style="bold red"
            )
        else:
            console.print(
                f"Error reading the pyproject.toml file: {e}", style="bold red"
            )

View on GitHub (pinned to 754d7323be)

Solutions

  1. Add crewai (or a crewai[tools]-style dependency containing 'crewai') to [project].dependencies in pyproject.toml.
  2. Run the command from the crew project root, where the correct pyproject.toml lives.
  3. If you use optional-dependencies only, also list the base package in [project].dependencies.

Example fix

# before
[project]
dependencies = ["litellm", "pydantic"]

# after
[project]
dependencies = ["crewai", "litellm", "pydantic"]
Defensive patterns

Strategy: validation

Validate before calling

import tomllib
from pathlib import Path

def has_crewai_dep(pyproject: Path) -> bool:
    data = tomllib.loads(pyproject.read_text())
    deps = data.get("project", {}).get("dependencies", [])
    return any("crewai" in d for d in deps)

Prevention

When it happens

Trigger: Calling get_project_name/get_project_version/get_project_description (or anything using _get_project_attribute) in a directory whose pyproject.toml lacks 'crewai' in [project].dependencies — e.g. crewai only in [project.optional-dependencies], a dev/editable install not reflected in the TOML, or running from the framework's own repo.

Common situations: Running crewai CLI helpers from a non-crewai project or a fresh directory; dependencies declared under a different extra group; vendoring crewai without listing it; typo like 'crewAI-tools' only in optional-dependencies.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/374481a10bc93950. Report an issue: GitHub.