--- id: cmdstanpy version: "1.3.0" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # cmdstanpy — Python interface to CmdStan License: permissive · Maintenance: active · Downloads: 7.0M/mo ## What it is and what it does CmdStanPy is a lightweight wrapper around CmdStan, the command-line interface to the Stan probabilistic programming language. It lets you write statistical models in Stan's modeling language, compile them to executables, and run Bayesian inference—MCMC sampling, variational inference, and optimization—all from Python. The package handles model compilation, data passing, and result parsing, while keeping memory overhead low by default and storing output on a temporary filesystem during development. The interface is designed for both iterative model development and production workflows. It depends on numpy and pandas for numerical operations and data handling, plus tqdm for progress tracking and stanio for I/O. Because it calls compiled Stan executables rather than embedding C++ directly, installation is straightforward and the package remains modular—you use CmdStanPy to generate posterior samples, then use other tools for analysis and visualization. Use it for: - Fit Bayesian hierarchical models to experimental or observational data and extract posterior samples for inference. - Develop and test Stan models iteratively during research, with automatic compilation and temporary output storage. - Run multiple inference jobs across machines or clusters by scripting CmdStanPy to distribute analysis reproducibly. - Compare inference algorithms (MCMC, variational, optimization) on the same model without rewriting code. - Integrate Bayesian inference into Python data pipelines alongside pandas and numpy workflows. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. CmdStanPy provides a pure-Python interface to the Stan probabilistic programming language, enabling you to compile Stan models and run Bayesian inference algorithms without direct C++ interaction. Yes. CmdStanPy is actively maintained, has no known vulnerabilities, minimal dependencies, and a permissive license. Install it if you need to run Stan models from Python for Bayesian inference, statistical modeling, or probabilistic programming. The low friction and modular design make it a solid choice for both research and production use. ## Install pip install cmdstanpy uv add cmdstanpy poetry add cmdstanpy ## Installing cmdstanpy Before you install: Low friction: pure-Python wheel distribution with only four runtime dependencies (pandas, numpy, tqdm, stanio). Actively maintained with a recent release and ongoing repository activity. License in practice: BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must include the license text in distributions. Quickstart: pip install cmdstanpy from cmdstanpy import CmdStanModel model = CmdStanModel(stan_file='model.stan') fit = model.sample(chains=4, data=data_file) Requires Python 3.9 or later; CmdStan itself (the underlying C++ compiler and inference engine) must be installed separately or will be downloaded on first use. Verify before relying: - Whether CmdStan binaries are automatically downloaded and installed on first use, or if manual setup is required. - Memory and disk footprint of compiled Stan models and posterior samples for typical use cases. ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 7.0M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags bayesian inference python, stan interface cmdstan, probabilistic programming, mcmc sampling python, posterior sampling stan, bayesian modeling, statistical inference cmdstan, bayesian-inference, probabilistic-programming, mcmc [View on SkillFed](https://skillfed.io/packages/cmdstanpy) · [View on PyPI](https://pypi.org/project/cmdstanpy/)