Getting Started#

Note

StanBKT cannot be used in the same Python environment as PyStan due to conflicts between CmdStanPy and PyStan. If you have PyStan installed, create a separate virtual environment for StanBKT to avoid compatibility issues.

Requirements#

  • Python 3.12 or higher

  • C++ compiler and make (For Windows, refer to this note)

  • Supported OS: Windows, macOS, Linux

Warning

For Windows Users: StanBKT cannot be installed in a directory that uses OneDrive. Specifically users who have their company or institutional accounts listed in the path (e.g. C:UsersuserOneDrive - Institution Name (xyz.edu)Desktop`). This is because CmdStan fails to compile the needed c++ code in these directories.

Installation#

Tip

We strongly recommend installing StanBKT in a dedicated virtual environment.

The recommended way to install StanBKT is using uv, which is a modern Python package manager. You can install StanBKT with the following command:

Working with uv?

StanBKT can be installed using the following command:

Prefer pip?

StanBKT can be installed via pip from PyPI.

Setup#

Unlike other common Python packages, StanBKT requires additional setup after installation, due to its dependencies on CmdStan.

StanBKT provides a utility function stanbkt.utils.setup_cmdstanpy() to automate this setup process, which includes installing CmdStan and setting the appropriate environment variables. The following code should be run after installing StanBKT and only needs to be done once per machine.

Important

If you are on Windows, this setup process will install RTools which includes the c++ compiler and make binary required for CmdStan. For more details, see the CmdStanPy installation documentation.

from stanbkt.utils import setup_cmdstanpy

# set up CmdStanPy with 4 cores for parallel processing
# replace n_cores with the number of cores available
setup_cmdstanpy(n_cores=4)