Problems with installing cmdstanpy on win10

Dear Stan experts,

I am trying to install cmdstanpy on a win10 computer, however there is some warning in installing cmdstan.

import cmdstanpy
cmdstanpy.install_cmdstan()

Installing CmdStan version: 2.29.0
Install directory: C:\Users\KLIPS\.cmdstan
Downloading CmdStan version 2.29.0
Download successful, file: C:\Users\KLIPS\AppData\Local\Temp\tmpi_3ehdht
Unpacked download as cmdstan-2.29.0
Building version cmdstan-2.29.0
WARNING:cmdstanpy:CmdStan installation failed.
Command "make build" failed
'cut' is not recognized as an internal or external command,
operable program or batch file.
'cut' is not recognized as an internal or external command,
operable program or batch file.
process_begin: CreateProcess(NULL, expr >= 8, ...) failed.
mingw32-make: makefile:125: pipe: Bad file descriptor
INFO: Could not find files for the given pattern(s).
process_begin: CreateProcess(NULL, cp bin/windows-stanc bin/stanc.exe, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make: *** [bin/stanc.exe] Error 2
deleting tmpfiles dir: C:\Users\KLIPS\AppData\Local\Temp\tmpt9qr4j5j
done

Thanks

Hi

Could you try

install_cmdstan("2.28.2")

Hi, thank you for replying, but still does not work.

Do you have gcc compiler installed? Can you check gcc --version

1 Like

the gcc comiler is indeed installed, its version is 5.3.0.

Hi, can i manually download the cmdstan zip file and set the path to the file?

After I download the cmdstan file and set the path. There is some warning in compling the stan model:

INFO:cmdstanpy:compiling stan program, exe file: D:/PeoplesFolders/Guo/cmdstan-2.28.2/cmdstan-2.28.2/examples/bernoulli/bernoulli.exe
INFO:cmdstanpy:compiler options: stanc_options=None, cpp_options=None
ERROR:cmdstanpy:file D:\PeoplesFolders\Guo\cmdstan-2.28.2\cmdstan-2.28.2\examples\bernoulli\bernoulli.stan, exception Command: ['mingw32-make', 'D:/PeoplesFolders/Guo/cmdstan-2.28.2/cmdstan-2.28.2/examples/bernoulli/bernoulli.exe']
failed, returncode: 2, error: No such file or directory, stderr: 'cut' is not recognized as an internal or external command,
operable program or batch file.
'cut' is not recognized as an internal or external command,
operable program or batch file.
process_begin: CreateProcess(NULL, expr >= 8, ...) failed.
mingw32-make: makefile:114: pipe: Bad file descriptor
INFO: Could not find files for the given pattern(s).
The syntax of the command is incorrect.
mingw32-make: *** [stan/lib/stan_math/lib/sundials_5.7.0/src/nvector/serial/nvector_serial.o] Error 1 
ERROR:cmdstanpy:model compilation failed

ValueError                                Traceback (most recent call last)
<ipython-input-31-13ecf4144ff1> in <module>
      1 bernoulli_stan = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
----> 2 bernoulli_model = CmdStanModel(stan_file=bernoulli_stan)

~\anaconda3\lib\site-packages\cmdstanpy\model.py in __init__(self, model_name, stan_file, exe_file, compile, stanc_options, cpp_options, logger)
    179             self.compile()
    180             if self._exe_file is None:
--> 181                 raise ValueError(
    182                     'Unable to compile Stan model file: {}.'.format(
    183                         self._stan_file

ValueError: Unable to compile Stan model file

If you are using gcc from conda, install cmdstan from conda-forge

conda install cmdstan -c conda-forge

I’m not sure why is that cut line triggered and I still have not find a way to install it from conda. It comes with RTools.

1 Like

To build cmdstan in conda we use 3 extra packages beyond just gcc and make:

- m2-filesystem   
- m2-sed             
- m2-coreutils     

I’m pretty sure cut is in m2-coreutils

2 Likes

update: the problem is coming from the lib TBB Makefile which references cut - looks like conda-forge install is the way to go for Windows.

as cut is definitely part of coreutils, assuming it’s in m2-coreutils - GNU Coreutils 9.0

2 Likes