pola-rs/polars · error · ModuleNotFoundError

polars.testing.parametric requires the 'hypothesis'…

Error message

polars.testing.parametric requires the 'hypothesis' module\nPlease install it using the command: pip install hypothesis

What it means

Importing polars.testing.parametric without the optional 'hypothesis' dependency raises ModuleNotFoundError at import time. The parametric testing strategies are built on hypothesis, which polars does not install by default.

Solutions

  1. pip install hypothesis (or pip install 'polars[pytest]' / project dev extras that include it).
  2. Add hypothesis to test requirements (requirements-dev.txt / pyproject optional-dependencies).
  3. Guard tests with pytest.importorskip('polars.testing.parametric') when hypothesis is optional.

Example fix

# before
from polars.testing.parametric import dataframes  # ModuleNotFoundError

# after (shell)
pip install hypothesis
# then the import works
Defensive patterns

Strategy: fallback

Validate before calling

import importlib.util
if importlib.util.find_spec('hypothesis') is None:
    pytest.skip('hypothesis not installed')

Try / catch

try:
    import polars.testing.parametric as ptp
except ModuleNotFoundError:
    ptp = None
if ptp is None:
    pytest.skip('parametric tests require hypothesis')

Prevention

When it happens

Trigger: import polars.testing.parametric (or `from polars.testing.parametric import dataframes`) in an environment where hypothesis isn't installed; running parametric test suites on a minimal CI image.

Common situations: Fresh venv following old docs; CI runner without dev extras; users copying test code that assumes hypothesis from a monorepo with it preinstalled.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/f4a4e72cdd180df5. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/testing/parametric/__init__.py:8

from polars._dependencies import _HYPOTHESIS_AVAILABLE

if not _HYPOTHESIS_AVAILABLE:
    msg = (
        "polars.testing.parametric requires the 'hypothesis' module\n"
        "Please install it using the command: pip install hypothesis"
    )
    raise ModuleNotFoundError(msg)

from polars.testing.parametric.profiles import load_profile, set_profile
from polars.testing.parametric.strategies import (
    column,
    dataframes,
    dtypes,
    lists,
    series,
)

__all__ = [
    # strategies
    "dataframes",
    "series",
    "column",
    "dtypes",
    "lists",
    # profiles

View on GitHub (pinned to fe841f959e)