Pystan erroring on import

Hello.

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\pystan_init_.py in ()
7 import logging
8
----> 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\api.py in ()
11 import os
12
—> 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?

Hi,

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?

Hi,

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+https://github.com/stan-dev/cmdstanpy

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

python -m cmdstanpy.install_cmdstan -c

And then in python script

import cmdstanpy
cmdstanpy.utils.cxx_toolchain_path()

...

See https://github.com/stan-dev/cmdstanpy

@ahartikainen And would this help for fbprophet?

Yes, see https://github.com/facebook/prophet/blob/cb4f1dcc59e61bb292d6cefab8e61b2f77585088/README.md#installation-in-python