{"record":{"id":"3de265d17ecdc142","repo":"crewAIInc/crewAI","slug":"failed-to-install-patronus-package","errorCode":null,"errorMessage":"Failed to install 'patronus' package","messagePattern":"Failed to install 'patronus' package","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/patronus_eval_tool/patronus_local_evaluator_tool.py","lineNumber":76,"sourceCode":"            if PYPATRONUS_AVAILABLE:\n                self.client = patronus_client\n                self._generate_description()\n            else:\n                raise ImportError\n        except ImportError:\n            import click\n\n            if click.confirm(\n                \"You are missing the 'patronus' package. Would you like to install it?\"\n            ):\n                import subprocess\n\n                try:\n                    subprocess.run([\"uv\", \"add\", \"patronus\"], check=True)  # noqa: S607\n                    self.client = patronus_client\n                    self._generate_description()\n                except subprocess.CalledProcessError as e:\n                    raise ImportError(\"Failed to install 'patronus' package\") from e\n            else:\n                raise ImportError(\n                    \"`patronus` package not found, please run `uv add patronus`\"\n                ) from None\n\n    def _run(\n        self,\n        **kwargs: Any,\n    ) -> Any:\n        evaluated_model_input = kwargs.get(\"evaluated_model_input\")\n        evaluated_model_output = kwargs.get(\"evaluated_model_output\")\n        evaluated_model_retrieved_context = kwargs.get(\n            \"evaluated_model_retrieved_context\"\n        )\n        evaluated_model_gold_answer = self.evaluated_model_gold_answer\n        evaluator = self.evaluator\n\n        result: Any = self.client.evaluate(","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/patronus_eval_tool/patronus_local_evaluator_tool.py#L58-L94","documentation":"Raised by PatronusLocalEvaluatorTool when the user consented to the interactive install prompt but the underlying `uv add patronus` subprocess failed (non-zero exit). The tool attempts a just-in-time dependency install via subprocess with check=True; CalledProcessError is caught and re-raised as this ImportError, chained from the original failure.","triggerScenarios":"The patronus package is not importable, click.confirm returns True, and `uv add patronus` exits non-zero — e.g. uv is not on PATH in the current venv/container, the project is not a uv-managed workspace, pyproject.toml is read-only, network offline, or dependency resolution fails.","commonSituations":"Running inside Docker or CI where uv is not installed or PATH differs; running from a directory without a uv project; lockfile conflicts; restricted file permissions on pyproject.toml; no network access to PyPI.","solutions":["Install patronus manually: uv add patronus (or pip install patronus) from the project root, then rerun","If uv is missing, install it (curl -LsSf https://astral.sh/uv/install.sh | sh) or pre-install the package with pip so the prompt never appears","Run the process from the uv project root with a writable pyproject.toml/uv.lock","Check the chained CalledProcessError (__cause__) for the real uv failure (network, resolver, permissions)","Pre-install dependencies in Docker/CI images so the interactive prompt path is never hit"],"exampleFix":"# before\npython run_agent.py  # prompt accepted, uv missing -> ImportError\n\n# after (pre-install in Dockerfile / CI)\nRUN uv add patronus\n# or: RUN pip install patronus\n","handlingStrategy":"try-catch","validationCode":"import importlib.util, shutil\n\ndef patronus_installable() -> bool:\n    return importlib.util.find_spec(\"patronus\") is not None or shutil.which(\"uv\") is not None","typeGuard":null,"tryCatchPattern":"try:\n    tool = PatronusLocalEvaluatorTool(...)\nexcept ImportError as e:\n    if \"install\" in str(e).lower():\n        subprocess.run([\"pip\", \"install\", \"patronus\"], check=True)\n        tool = PatronusLocalEvaluatorTool(...)\n    else:\n        raise","preventionTips":["Pre-install patronus in Docker/CI images","Ensure uv is on PATH in the exact environment the tool runs in","Never rely on the interactive click.confirm path in non-interactive pipelines","Inspect the chained CalledProcessError to find the real uv failure"],"tags":["installation","dependencies","subprocess","uv","patronus"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}