Cannot Install PyStan with Support for Stiff ODE Sovers

Operating System:Windows 7
Interface Version: PyStan 2.19
Compiler/Toolkit: Anaconda

According to the PyStan website, to get support for ODEs, I need to be able to access the SUNDIALS library. It recommends install PyStan via:

pip install https://github.com/stan-dev/pystan/archive/v2.18.0.0-cvodes.tar.gz

However, when typing this into my Anaconda prompt I get the following error:

(base) C:>pip install https://github.com/stan-dev/pystan/archive/v2.18.0.0-cvod
es.tar.gz
Collecting https://github.com/stan-dev/pystan/archive/v2.18.0.0-cvodes.tar.gz
Downloading https://github.com/stan-dev/pystan/archive/v2.18.0.0-cvodes.tar.gz

 / 614kB 595kB/s
ERROR: Command errored out with exit status 1:
 command: 'C:\Users\dms228\AppData\Local\Continuum\anaconda3\python.exe' -c

‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’“‘C:\Users\dms228\AppData
\Local\Temp\pip-req-build-qpf7j9du\setup.py’”’“‘; file=’”‘“‘C:\Users\d
ms228\AppData\Local\Temp\pip-req-build-qpf7j9du\setup.py’”’“';f=getattr(tok
enize, '”‘“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’
"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ egg_info --e
gg-base ‘C:\Users\dms228\AppData\Local\Temp\pip-req-build-qpf7j9du\pip-egg-info’

     cwd: C:\Users\dms228\AppData\Local\Temp\pip-req-build-qpf7j9du\
Complete output (5 lines):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\dms228\AppData\Local\Temp\pip-req-build-qpf7j9du\setup.py",

line 124, in
logger.warning(“MSVC is not supported”)
NameError: name ‘logger’ is not defined
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check th
e logs for full command output.

According to a thread with a similar problem on this forum, an alternative solution seems to be:

git clone --recursive https://github.com/stan-dev/pystan
cd pystan
git checkout sundials_update
pip install .
# or inplace
#pip install -e 

However, when I try to type this into the prompt, I get this error:

(base) C:>git clone --recursive GitHub - stan-dev/pystan: PyStan, a Python interface to Stan, a platform for statistical modeling. Documentation: https://pystan.readthedocs.io
‘git’ is not recognized as an internal or external command,
operable program or batch file.

I feel like I’m probably misunderstanding some instructions. Any advice on what I’m doing wrong?

Hi, first you need to setup your python environment (e.g. anaconda)

https://pystan.readthedocs.io/en/latest/windows.html

also install git commandline tools

conda install git

Then do

pip install git+https://github.com/stan-dev/pystan@cvodes

Hi Ari,

Many thanks for your help. I have managed to successfully follow your instructions up to the last part. It throws out the following error:

UPDATE: Having cleared some space on my drive, I tried running the command again, and now have a new error:

(stan_env) C:>pip install git+https://github.com/stan-dev/pystan@cvodes
Collecting git+https://github.com/stan-dev/pystan@cvodes
Cloning GitHub - stan-dev/pystan: PyStan, a Python interface to Stan, a platform for statistical modeling. Documentation: https://pystan.readthedocs.io (to revision cvodes) to c:\users\dm
s228\appdata\local\temp\pip-req-build-1k4co6ua
Running command git clone -q GitHub - stan-dev/pystan: PyStan, a Python interface to Stan, a platform for statistical modeling. Documentation: https://pystan.readthedocs.io ‘C:\Users\dms2
28\AppData\Local\Temp\pip-req-build-1k4co6ua’
Running command git checkout -b cvodes --track origin/cvodes
Branch ‘cvodes’ set up to track remote branch ‘cvodes’ from ‘origin’.
Switched to a new branch ‘cvodes’
Running command git submodule update --init --recursive -q
error: unable to create file lib/boost_1.69.0/libs/geometry/doc/html/geometry/
reference/spatial_indexes/boost__geometry__index__rtree/rtree_parameters_type_co
nst____indexable_getter_const____value_equal_const____allocator_type_const___.ht
ml: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1channel__mapping__type_3_01planar__pixel__reference_3_01_chann
el_reference60971d1be7c73d78ff725e654349b4f8.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1color__converted__view__type_3_01any__image__view_3_01_view_ty
pes_01_4_00_01_dst_p_00_01_c_c_01_4-members.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1color__space__type_3_01planar__pixel__reference_3_01_channel_r
eference_00_4fb1a46a79bb525d815c77d4e7feb3e2.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1copier__n_3_01iterator__from__2d_3_01_i_l_01_4_00_01
iterator__fr9b29768443232234f95320b3f7e74729.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1equal__n__fn_3_01boost_1_1gil_1_1iterator__from__2d_
3_01_loc1_01629d3bb430b0f68b56ea86189659092c.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1equal__n__fn_3_01boost_1_1gil_1_1iterator__from__2d_
3_01_loc1_0173caba61dca2b882aec2f645342d0509.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1equal__n__fn_3_01const_01pixel_3_01_t_00_01_cs_01_4_
01_5_00_01cof2dcbb9935c1f0c43d9a16609dbdbb2f.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1equal__n__fn_3_01const_01pixel_3_01_t_00_01_cs_01_4_
01_5_00_01cof677edf535b9930129958a7a23f04e18.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1equal__n__fn_3_01planar__pixel__iterator_3_01_i_c_00
_01_cs_01_4_24c83e783e21d37b62022997a2dbc869.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1detail_1_1equal__n__fn_3_01planar__pixel__iterator_3_01_i_c_00
_01_cs_01_4_5f4582bc2983f880fe38ecee99cfc579.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1iterator__add__deref_3_01dereference__iterator__adaptor_3_01_i
terator_00_0927b7f3fa453e9b4decea8a0c8e52f27.html: Filename too long
error: unable to create file lib/boost_1.69.0/libs/gil/doc/html/reference/stru
ctboost_1_1gil_1_1iterator__add__deref_3_01dereference__iterator__adaptor_3_01_i
terator_00_099dd338dfbc32474aacfee6846d34880.html: Filename too long
Unable to checkout ‘5681e4294bc57224b7c8093293854c05116c8fc0’ in submodule pat
h ‘pystan/stan/lib/stan_math’
Failed to recurse into submodule path ‘pystan/stan’
ERROR: Command errored out with exit status 1: git submodule update --init --rec
ursive -q Check the logs for full command output.

Ok, this bit is the annoying path limit. Let me see if I can fix it for you. This is actually fix with the current Stan codebase, but PyStan has not yet updated to the latests Stan (I hope we have a new version soon)

So first config your git tool

git config --system core.longpaths true

Then try again, it might still fail. If it fails, please clone pystan to suitable folder

git clone --recursive https://github.com/stan-dev/pystan
cd pystan
git checkout cvodes

Remove docs and tests for stan-math libraries

FOR /D /R "pystan/stan/lib/stan_math/lib" %D IN (doc) DO @IF EXIST "%D" RD /S /Q "%D"
FOR /D /R "pystan/stan/lib/stan_math/lib" %D IN (test) DO @IF EXIST "%D" RD /S /Q "%D"

Build a wheel (which can be installed as pip install wheelname.whl)

python setup.py bdist_wheel

or just do pip install

python -m pip install .

Hi Ari,

Just managed to install Pystan 2.19 using the clone method. It now works with ODEs. Thanks so much for your help.

1 Like