cmdstanpy
Python interface to CmdStan
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- 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.
- 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 · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; you must include the license text in distributions.
last release 2025-10-20 (298 days) · last repo commit 2026-08-03 · 199 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,992,043 downloads/mo, #1,800 on PyPI
Alternatives
Verify before relying
pip install cmdstanpy
from cmdstanpy import CmdStanModel
model = CmdStanModel(stan_file='model.stan')
fit = model.sample(chains=4, data=data_file)- 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.
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 on this page. Verify before relying on it.
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
cmdstanpy on PyPI
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.
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.
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)
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 the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagespandasnumpytqdmstanio |
| Maintenance | Actively maintained 298 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,992,043 / month, #1,800 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Information Analysis |
Evidence: cmdstanpy-1.3.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “stan interface cmdstan”
- cmdstanpyCmdStanPy provides a pure-Python interface to the Stan probabilistic…
- httpstanhttpstan provides an HTTP REST interface to the Stan C++ library for…
- stanioStanIO converts Python dictionaries to Stan-compatible JSON and reads…
Give your agent the search over MCP, or paste the wish link into any chat.
More Information Analysis packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyarrow provides Python bindings to Apache Arrow's C++ libraries for efficient columnar data processing, serialization, and interoperability with pandas, NumPy, and other Python ecosystem tools.
NetworkX provides data structures and algorithms for creating, analyzing, and manipulating graphs and networks, supporting everything from simple undirected graphs to complex directed and weighted networks.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
ContourPy calculates contours of 2D quadrilateral grids using C++11 algorithms wrapped in Python, offering serial and multithreaded implementations without requiring Matplotlib as a dependency.
Snowpark Python provides APIs to query and process data directly in Snowflake without moving data to your local system, with support for both native Snowpark and pandas-compatible interfaces.
Install it if you use Snowflake and want to process data without moving it to your application layer.
See also pystan · stanio · httpstan · pymc3 · nutpie · pymc · numpyro · tensorflow-probability · emcee · pgmpy