Installation#
PyVBMC is available via pip and conda-forge and requires Python 3.10
or newer.
Basic installation#
Install or upgrade PyVBMC with pip:
python -m pip install --upgrade pyvbmc
Or install it with Conda:
conda install --channel=conda-forge pyvbmc
PyVBMC 1.5 requires NumPy 2.0, SciPy 1.15 and matplotlib 3.9 or newer, and
its conda-forge package requires Python 3.11 or newer. In an environment
that holds an older version of one of them, conda can install PyVBMC
1.0.4 instead, without a warning: ask it for "pyvbmc>=1.5", or see the
FAQ.
To learn whether a newer release exists and how to update, see the FAQ.
Optional integrations#
Torch#
The to_torch() export and the
SVBMC class (stacking the posteriors of several
VBMC runs) require torch 2.7 or newer. For a CPU-only installation, install
torch from its official CPU wheel index first, then install the PyVBMC
extra:
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
python -m pip install --upgrade "pyvbmc[torch]"
Installing torch first ensures that pip selects a CPU wheel. If your model or
export will run on an accelerator, follow the torch installation selector for your platform before
installing pyvbmc[torch].
With Conda, install the named packages directly:
conda install --channel=conda-forge "pyvbmc>=1.5" pytorch
ArviZ#
The to_arviz() export uses the current
ArviZ DataTree format and requires Python 3.12 or newer. Install it with:
python -m pip install --upgrade "pyvbmc[arviz]"
PyVBMC itself continues to support Python 3.10 and newer. On Python 3.10 or
3.11, pip does not install the ArviZ dependencies because of their Python
version marker, and to_arviz is unavailable. With Conda, install the
corresponding packages directly:
conda install --channel=conda-forge "pyvbmc>=1.5" arviz arviz-base
PyMC#
The PyMCTarget adapter requires Python 3.12 or newer.
Install PyMC and the ArviZ data interface with:
python -m pip install --upgrade "pyvbmc[pymc]"
The adapter is tested with PyMC 6.3.2, PyTensor 3.3.1–3.3.3 and ArviZ 1.3.0,
using PyTensor’s default Numba linker on Windows and Linux. PyVBMC itself
continues to support Python 3.10 and newer; on Python 3.10 or 3.11, pip does
not install the PyMC dependencies because of their Python version marker, and
PyMCTarget is unavailable. With Conda, install the named packages
directly:
conda install --channel=conda-forge "pyvbmc>=1.5" pymc
The bracketed torch, arviz and pymc names are pip dependency
groups; they are not Conda package names. All three integrations are optional
and loaded on demand.
Examples and tests#
Install Jupyter Notebook to run the examples.
You can skip this step if your environment already has Jupyter Notebook,
but an unrelated jupyter executable on your path can cause import errors:
python -m pip install notebook
or, with Conda:
conda install --channel=conda-forge jupyter
Open the example notebooks with:
python -m pyvbmc
Example 2 uses plotly for one interactive figure. Install it with:
python -m pip install --upgrade "pyvbmc[examples]"
PyVBMC Example 9: Torch and JAX models and posterior exports uses both posterior exports and requires Python 3.12 or newer. A CPU-only environment is sufficient. Install its PyVBMC dependencies with:
python -m pip install --upgrade "pyvbmc[torch,arviz]"
Install JAX separately to run the short JAX target section, following the JAX installation guide. JAX is not required for the Torch target or posterior-export sections.
The test suite is included in the source distribution and repository. To run it, follow the Installation instructions for developers, then run this command from the PyVBMC repository root:
python -m pytest --reruns=5 -x
The --reruns=5 argument retries a failed test up to five times because
some tests are stochastic. The complete suite can take 20–30 minutes or
longer, depending on the hardware.
To install directly from the latest source, see the Installation instructions for developers.