Skip to content

Diagnostics

A crash in compiled code often depends more on the environment than on the call that set it off. show_versions collects the parts of the environment that have mattered: the numba threading layer, the OpenMP runtimes loaded, and whether Python runs under Rosetta 2 or is a free-threaded build. It is truecell's counterpart to R's sessionInfo(). Troubleshooting covers what to do with its output.

show_versions

show_versions(as_dict: bool = False) -> dict[str, Any] | None

Print what a bug report about a crash needs.

Run it in the environment that crashed, with python -c "import truecell; truecell.show_versions()", and paste the output into the issue beside the traceback from python -X faulthandler.

It reports where the running truecell lives and how it was installed; the interpreter, platform and processor, including whether Python runs under Rosetta 2 or is a free-threaded build; the version of each package in the scientific stack and the installer that put it there (pip, uv, conda); numba's threading layer; the OpenMP and BLAS runtimes threadpoolctl finds loaded; and the environment variables that change any of those. It ends with a warning for each known cause of a crash it sees, such as two copies of LLVM's OpenMP runtime in one process.

numba is examined in separate Python processes: one imports scikit-learn and runs a numba parallel function, and one per threading layer tries to load that layer. Calling this therefore cannot choose a layer or load a runtime in your own session, and a probe that crashes is reported rather than raised. The probes take a few seconds.

Parameters:

  • as_dict (bool, default: False ) –

    return the report instead of printing it

Returns:

  • ``None`` once the report is printed, or the report itself with –
  • ``as_dict=True``. –
Source code in truecell/_show_versions.py
def show_versions(as_dict: bool = False) -> dict[str, Any] | None:
    """Print what a bug report about a crash needs.

    Run it in the environment that crashed, with
    ``python -c "import truecell; truecell.show_versions()"``, and paste the
    output into the issue beside the traceback from ``python -X faulthandler``.

    It reports where the running truecell lives and how it was installed; the
    interpreter, platform and processor, including whether Python runs under
    Rosetta 2 or is a free-threaded build; the version of each package in the
    scientific stack and the installer that put it there (``pip``, ``uv``,
    ``conda``); numba's threading layer; the OpenMP and BLAS runtimes
    ``threadpoolctl`` finds loaded; and the environment variables that change
    any of those. It ends with a warning for each known cause of a crash it
    sees, such as two copies of LLVM's OpenMP runtime in one process.

    numba is examined in separate Python processes: one imports scikit-learn
    and runs a numba parallel function, and one per threading layer tries to
    load that layer. Calling this therefore cannot choose a layer or load a
    runtime in your own session, and a probe that crashes is reported rather
    than raised. The probes take a few seconds.

    Parameters
    ----------
    as_dict : return the report instead of printing it

    Returns
    -------
    ``None`` once the report is printed, or the report itself with
    ``as_dict=True``.
    """
    report: dict[str, Any] = {
        "truecell": _truecell(),
        "system": _system(),
        "dependencies": {name: _distribution(name) for name in _DEPENDENCIES},
    }
    report["numba"], fresh_pools = _numba()
    report["threadpools"] = {"this_process": _threadpools(), "fresh_process": fresh_pools}
    report["environment"] = _environment()
    report["warnings"] = _warnings(report)
    if as_dict:
        return report
    print(_format(report))
    return None