distutils.errors.CompileError: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1

Hello everyone, I am unable to run my Pystan / Orbit ML code. I am getting distutils.errors.CompileError: command ‘C:\MinGW\bin\gcc.exe’ failed with exit status 1 error while running my python code.

As mentioned in the group, I have already installed gcc compiler and added distutlis.cfg file. Still I am unable to run Pystan code.
Python Version: Python 3.6.5 :: Anaconda, Inc.
OS : Windows 10
GCC: gcc (MinGW.org GCC Build-2) 9.2.0

Here is the detailed error:
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_f7eb4ed4486a30ffc26b04f2ada67b48 NOW.
Traceback (most recent call last):
File “C:\ProgramData\Anaconda3\lib\distutils\cygwinccompiler.py”, line 173, in _compile
File “C:\ProgramData\Anaconda3\lib\distutils\ccompiler.py”, line 909, in spawn
spawn(cmd, dry_run=self.dry_run)
File “C:\ProgramData\Anaconda3\lib\distutils\spawn.py”, line 38, in spawn
_spawn_nt(cmd, search_path, dry_run=dry_run)
File “C:\ProgramData\Anaconda3\lib\distutils\spawn.py”, line 81, in _spawn_nt
“command %r failed with exit status %d” % (cmd, rc))
distutils.errors.DistutilsExecError: command ‘C:\MinGW\bin\gcc.exe’ failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:/ProgramData/Anaconda3/envs/Forecasting_Algorithms/orbit_ml.py”, line 35, in
File “C:\ProgramData\Anaconda3\envs\Temp\Forecasting_Algorithms\lib\site-packages\orbit\forecaster\full_bayes.py”, line 29, in fit
super().fit(df, sampling_temperature=sampling_temperature)
File “C:\ProgramData\Anaconda3\envs\Temp\Forecasting_Algorithms\lib\site-packages\orbit\forecaster\forecaster.py”, line 169, in fit
File “C:\ProgramData\Anaconda3\envs\Temp\Forecasting_Algorithms\lib\site-packages\orbit\estimators\stan_estimator.py”, line 118, in fit
compiled_stan_file = get_compiled_stan_model(model_name)
File “C:\ProgramData\Anaconda3\envs\Temp\Forecasting_Algorithms\lib\site-packages\orbit\utils\stan.py”, line 62, in get_compiled_stan_model
compiled_model = compile_stan_model(stan_model_name)
File “C:\ProgramData\Anaconda3\envs\Temp\Forecasting_Algorithms\lib\site-packages\orbit\utils\stan.py”, line 49, in compile_stan_model
sm = StanModel(model_code=model_code)
File “C:\ProgramData\Anaconda3\envs\Temp\Forecasting_Algorithms\lib\site-packages\pystan\model.py”, line 378, in init
File “C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py”, line 339, in run
File “C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py”, line 448, in build_extensions
File “C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py”, line 473, in _build_extensions_serial
File “C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py”, line 533, in build_extension
File “C:\ProgramData\Anaconda3\lib\distutils\ccompiler.py”, line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File “C:\ProgramData\Anaconda3\lib\distutils\cygwinccompiler.py”, line 175, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command ‘C:\MinGW\bin\gcc.exe’ failed with exit status 1

Let me know your thoughts.

Sorry this didn’t get answered sooner. And I’m afraid I’m not going to be able to answer. But I can kick it over to the PyStan interface group and let @ariddell know you have a question.

You might also want to try cmdstanpy, which is a more lightweight interface to Stan with less functionality, but an easier install process.


There are many things that can go wrong with PyStan + Windows + Anaconda

I recommend following PyStan on Windows — PyStan documentation

There might be a need to add distutils.cfg also in to site-packages/setuptools/_distutils folder, not sure.

Also use python < 3.9.