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:Truera Trulens Python Core Environment

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

Overview

Python 3.9+ environment with OpenTelemetry SDK, SQLAlchemy, Pydantic 2, and NumPy for the trulens-core evaluation library.

Description

This environment provides the foundational runtime for all TruLens operations. It is built on Python 3.9+ with the OpenTelemetry SDK for distributed tracing, SQLAlchemy 2.0 for database persistence, and Pydantic 2 for data validation. The core package supports OS-independent operation and includes automatic MKL multiprocessing compatibility via the KMP_DUPLICATE_LIB_OK workaround. OpenTelemetry tracing is enabled by default but can be toggled via environment variables.

Usage

Use this environment for any TruLens workflow including session initialization, feedback function definition, application recording, and result retrieval. This is the mandatory base environment that all other TruLens packages depend on.

System Requirements

Category Requirement Notes
OS Any (OS Independent) Linux, macOS, Windows all supported
Python >= 3.9 Some sub-packages restrict to < 3.13; Dashboard excludes 3.9.7
Disk Minimal SQLite default DB; configurable to Postgres/Snowflake

Dependencies

Python Packages

  • `trulens-otel-semconv` >= 2.0.0
  • `opentelemetry-api` >= 1.23.0
  • `opentelemetry-sdk` >= 1.23.0
  • `opentelemetry-proto` >= 1.23.0
  • `numpy` >= 1.23.0
  • `munch` >= 2.5.0, < 5.0.0
  • `dill` >= 0.3.8
  • `typing_extensions` >= 4.9
  • `pydantic` >= 2.4.2
  • `pandas` >= 1.0.0
  • `rich` >= 13.6.0
  • `sqlalchemy` >= 2.0
  • `alembic` >= 1.8.1
  • `nest-asyncio` >= 1.5
  • `python-dotenv` >= 0.21, < 2.0
  • `requests` >= 2.31
  • `packaging` >= 23.0
  • `importlib-resources` >= 6.0
  • `wrapt` >= 1.17.0

Optional Packages

  • `tqdm` >= 4.2.0 (progress bars)
  • `trulens-feedback` >= 2.0.0 (feedback functions)

Credentials

The following environment variables may be configured:

  • `TRULENS_OTEL_TRACING`: Set to `0` or `false` to disable OpenTelemetry tracing (enabled by default).
  • `TRULENS_OTEL_BACKWARDS_COMPATIBILITY`: Set to `0` or `false` to disable legacy OTEL compatibility mode.
  • `SQLALCHEMY_URL`: Database URL for trace/feedback persistence (defaults to local SQLite).
  • `KMP_DUPLICATE_LIB_OK`: Automatically set to `TRUE` by trulens-core to avoid MKL multiprocessing crashes.

Quick Install

# Install trulens-core with all required dependencies
pip install trulens-core>=2.6.0

# Optional: Install with feedback functions
pip install trulens-core[feedback]>=2.6.0

Code Evidence

MKL multiprocessing workaround from `src/core/trulens/core/__init__.py:19-21`:

# NOTE: workaround for MKL and multiprocessing
# https://github.com/pytorch/csprng/issues/115
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"

OTEL tracing toggle from `src/core/trulens/core/otel/utils.py:14-19`:

def is_otel_tracing_enabled() -> bool:
    """Check if OpenTelemetry tracing is enabled.

    Returns True by default unless TRULENS_OTEL_TRACING is explicitly set to "0" or "false".
    """
    return not _is_env_var_disabled("TRULENS_OTEL_TRACING")

Python version compatibility from `src/core/trulens/core/_utils/pycompat.py:31`:

if sys.version_info >= (3, 11):
    from inspect import getmembers_static

Common Errors

Error Message Cause Solution
`Cannot find TruLens context` No active TruSession when recording Create a `TruSession()` before using `with` context manager
`KMP_DUPLICATE_LIB_OK` related crash MKL library conflict with multiprocessing Automatically handled by trulens-core init; ensure trulens.core is imported first
`ModuleNotFoundError: trulens_eval` Using deprecated package name Migrate to `trulens-core`; see DEPRECATION.md

Compatibility Notes

  • Python 3.9.7: Explicitly excluded by trulens-dashboard and trulens_eval due to a known bug. Use 3.9.8+ or any later minor version.
  • Python 3.13+: Snowflake Connector, Cortex provider, and NeMo apps are not compatible with Python 3.13+. Use Python 3.12 or earlier for those packages.
  • Python 3.11+: Enables `inspect.getmembers_static` for improved introspection performance.
  • Python 3.10+: Enables `types.NoneType` for cleaner type handling.

Related Pages

Page Connections

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