Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Vibrantlabsai Ragas Python 3 9 Core Environment

From Leeroopedia
Knowledge Sources
Domains Infrastructure, LLM_Evaluation
Last Updated 2026-02-12 10:00 GMT

Overview

Python 3.9+ environment with core dependencies for running the Ragas LLM evaluation framework, including OpenAI, LangChain, Pydantic, NumPy, and async utilities.

Description

This environment provides the base runtime context for the Ragas evaluation toolkit. It requires Python 3.9 or higher and includes core dependencies for LLM interaction (OpenAI, LangChain ecosystem), data handling (NumPy, datasets, Pydantic), tokenization (tiktoken), async execution (nest-asyncio), caching (diskcache), CLI (typer, rich), and graph analysis (networkx, scikit-network). This is the minimum environment needed to run any Ragas evaluation.

Usage

Use this environment for all Ragas operations including metric evaluation, test data generation, and experiment tracking. Every Ragas workflow requires this base environment. Optional features like NLP metrics, Google Drive backend, or specific integrations require additional packages installed separately.

System Requirements

Category Requirement Notes
OS Linux, macOS, Windows Cross-platform Python support
Python >= 3.9 Configured via `requires-python` in pyproject.toml
Disk ~500MB For dependencies and cache directory

Dependencies

System Packages

  • No system-level packages required for core functionality

Python Packages

Core Dependencies (from pyproject.toml):

  • `numpy` >= 1.21.0, < 3.0.0
  • `datasets` >= 4.0.0
  • `tiktoken` (any version)
  • `pydantic` >= 2.0.0
  • `nest-asyncio` (any version)
  • `appdirs` (any version)
  • `diskcache` >= 5.6.3
  • `typer` (any version)
  • `rich` (any version)
  • `openai` >= 1.0.0
  • `tqdm` (any version)
  • `instructor` (any version)
  • `pillow` >= 10.4.0
  • `networkx` (any version)
  • `scikit-network` (any version)
  • `langchain` (any version)
  • `langchain-core` (any version)
  • `langchain-community` (any version)
  • `langchain_openai` (any version)

Credentials

The following environment variables are used by the core library:

  • `OPENAI_API_KEY`: Required by the default LLM provider (OpenAI) for evaluation and generation.
  • `RAGAS_DO_NOT_TRACK`: Set to `true` to opt out of anonymous usage analytics.
  • `RAGAS_DEBUG`: Set to `true` to enable debug logging mode.
  • `__RAGAS_DEBUG_TRACKING`: Developer-only flag for debugging analytics event payloads.
  • `RAGAS_CACHE_HOME`: Custom cache directory path (default: `~/.cache/ragas`).
  • `XDG_CACHE_HOME`: XDG standard cache directory (default: `~/.cache`).

Quick Install

# Install Ragas with core dependencies
pip install ragas

# Or install from source (editable)
pip install -e "."

# With UV (recommended for development)
uv pip install -e "."

Code Evidence

Python version requirement from `pyproject.toml:4`:

requires-python = ">=3.9"

Cache directory resolution from `src/ragas/utils.py:29-35`:

@lru_cache(maxsize=1)
def get_cache_dir() -> str:
    "get cache location"
    DEFAULT_XDG_CACHE_HOME = "~/.cache"
    xdg_cache = os.getenv("XDG_CACHE_HOME", DEFAULT_XDG_CACHE_HOME)
    default_ragas_cache = os.path.join(xdg_cache, "ragas")
    return os.path.expanduser(os.getenv("RAGAS_CACHE_HOME", default_ragas_cache))

Debug mode detection from `src/ragas/utils.py:38-43`:

@lru_cache(maxsize=1)
def get_debug_mode() -> bool:
    if os.environ.get(DEBUG_ENV_VAR, str(False)).lower() == "true":
        return True
    else:
        return False

Analytics opt-out from `src/ragas/_analytics.py:46-49`:

@lru_cache(maxsize=1)
def do_not_track() -> bool:
    return os.environ.get(RAGAS_DO_NOT_TRACK, str(False)).lower() == "true"

Common Errors

Error Message Cause Solution
`ImportError: unknown version` Package installed without version metadata (e.g., editable install without setuptools_scm) Run `pip install -e "."` from the repo root or install from PyPI
`ImportError: nest_asyncio` Running in Jupyter without nest_asyncio `pip install nest-asyncio`
`ImportError: diskcache` diskcache not installed `pip install diskcache>=5.6.3`

Compatibility Notes

  • Python 3.9: Minimum supported version. Some typing features use `typing_extensions` as fallback.
  • Pyright: Type checking configured for Python 3.9 target with `basic` mode.
  • Build System: Requires `setuptools>=64` and `setuptools_scm>=8` for building from source.
  • UV Workspace: The project uses UV workspace configuration with two members: `ragas` (main) and `examples`.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment