crewAIInc/crewAI · error · ImportError

`databricks-sdk` package not found, please run `uv add datab

Error message

`databricks-sdk` package not found, please run `uv add databricks-sdk`

What it means

DatabricksQueryTool lazily builds a databricks.sdk WorkspaceClient in its workspace_client property. The first access does 'from databricks.sdk import WorkspaceClient'; if the databricks-sdk distribution is not installed in the current interpreter, the ImportError is caught and re-raised as this message instructing 'uv add databricks-sdk'. Note the name mismatch: the PyPI package is databricks-sdk, the import root is databricks.sdk.

Source

Thrown at lib/crewai-tools/src/crewai_tools/tools/databricks_query_tool/databricks_query_tool.py:165

            "DATABRICKS_HOST" in os.environ and "DATABRICKS_TOKEN" in os.environ
        )

        if not (has_profile or has_direct_auth):
            raise ValueError(
                "Databricks authentication credentials are required. "
                "Set either DATABRICKS_CONFIG_PROFILE or both DATABRICKS_HOST and DATABRICKS_TOKEN environment variables."
            )

    @property
    def workspace_client(self) -> WorkspaceClient:
        """Get or create a Databricks WorkspaceClient instance."""
        if self._workspace_client is None:
            try:
                from databricks.sdk import WorkspaceClient

                self._workspace_client = WorkspaceClient()
            except ImportError as e:
                raise ImportError(
                    "`databricks-sdk` package not found, please run `uv add databricks-sdk`"
                ) from e
        return self._workspace_client

    def _format_results(self, results: list[dict[str, Any]]) -> str:
        """Format query results as a readable string."""
        if not results:
            return "Query returned no results."

        if not results[0]:
            return "Query returned empty rows with no columns."

        columns = list(results[0].keys())

        if not columns:
            return "Query returned rows but with no column data."

        # Calculate column widths based on data

View on GitHub (pinned to 754d7323be)

Solutions

  1. Install the SDK: uv add databricks-sdk (or pip install databricks-sdk).
  2. Verify the import works in the same interpreter the tool runs under: python -c "from databricks.sdk import WorkspaceClient".
  3. If you installed 'databricks' by mistake, uninstall it and install 'databricks-sdk'.
  4. Add databricks-sdk to your Dockerfile / requirements / lockfile so it is always present.

Example fix

# before
tool = DatabricksQueryTool()
tool.run(query="SELECT 1")  # ImportError: `databricks-sdk` package not found

# after
# shell:
#   uv add databricks-sdk
tool.run(query="SELECT 1")
Defensive patterns

Strategy: validation

Validate before calling

def databricks_sdk_available() -> bool:
    try:
        from databricks.sdk import WorkspaceClient  # noqa: F401
        return True
    except ImportError:
        return False

Try / catch

try:
    client = tool.workspace_client
except ImportError as e:
    if "databricks-sdk" in str(e):
        raise SystemExit("Install databricks-sdk (uv add databricks-sdk) and rerun") from e
    raise

Prevention

When it happens

Trigger: Accessing tool.workspace_client (directly or by calling tool._run/query) in an environment without databricks-sdk installed; installing 'databricks' (a different legacy package) instead of 'databricks-sdk'; tool running under a different venv/interpreter than the one where you installed the SDK.

Common situations: Missing optional dependency when crewai-tools is installed without the databricks extra; CI image lacking the package; confusing 'databricks' vs 'databricks-sdk' on PyPI; pip install into the wrong environment.

Related errors


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