Pystan erroring on import


I just installed pystan via pip install pystan and when I try to import I get the following error:

ImportError Traceback (most recent call last)
in ()
----> 1 import pystan

C:\ProgramData\Anaconda3\lib\site-packages\ in ()
7 import logging
----> 9 from pystan.api import stanc, stan
10 from pystan.misc import read_rdump, stan_rdump, stansummary
11 from pystan.diagnostics import check_hmc_diagnostics

C:\ProgramData\Anaconda3\lib\site-packages\pystan\ in ()
11 import os
—> 13 import pystan._api # stanc wrapper
14 from pystan._compat import string_types, PY2
15 from pystan.model import StanModel

ImportError: DLL load failed: The specified module could not be found.

There are some github errors but I’m not seeing a solution that’s working. Has anyone ran into this before?


First, can you try to install pystan on a fresh conda environment

conda create -n stan_env python==3.7 numpy scipy matplotlib libpython m2w64-toolchain -c conda-forge -c msys2

conda activate stan_env

python -m pip install pystan

If you still have DLL problems, maybe try with

conda install pystan -c conda-forge

Hi @ahartikainen Anaconda cannot be used commercially unless license, so any workaround to make pystan work on windows through pip?


Would WSL work?

Then there is possibility to use CmdStanPy which can use RTools compiler setup.

This is a new workflow to get things running on Windows (currently still in github master)

#pip install cmdstanpy
# current master
pip install git+

Install CmdStan+toolchain (current master) (will save in %HOME%/.cmdstanpy)

python -m cmdstanpy.install_cmdstan -c

And then in python script

import cmdstanpy



@ahartikainen And would this help for fbprophet?

Yes, see