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

**URL:** <https://discourse.mc-stan.org/t/distutils-errors-compileerror-command-c-mingw-bin-gcc-exe-failed-with-exit-status-1/28921>\
**Category:** PyStan\
**Created:** [September 23, 2022, 11:25pm UTC](https://discourse.mc-stan.org/t/distutils-errors-compileerror-command-c-mingw-bin-gcc-exe-failed-with-exit-status-1/28921 "2022-09-23T23:25:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dj123](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/dj123/32/15078_2.png) [@dj123](https://discourse.mc-stan.org/u/dj123)\
**Post date:** [September 23, 2022, 11:25pm UTC](https://discourse.mc-stan.org/t/distutils-errors-compileerror-command-c-mingw-bin-gcc-exe-failed-with-exit-status-1/28921/1 "2022-09-23T23:25:29Z")

</div>

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](http://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  
extra\_postargs)  
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   
ets.fit(df=train\_df)  
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  
\*\*kwargs,  
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**  
build\_extension.run()  
File “C:\ProgramData\Anaconda3\lib\distutils\command\build\_ext.py”, line 339, in run  
self.build\_extensions()  
File “C:\ProgramData\Anaconda3\lib\distutils\command\build\_ext.py”, line 448, in build\_extensions  
self.\_build\_extensions\_serial()  
File “C:\ProgramData\Anaconda3\lib\distutils\command\build\_ext.py”, line 473, in \_build\_extensions\_serial  
self.build\_extension(ext)  
File “C:\ProgramData\Anaconda3\lib\distutils\command\build\_ext.py”, line 533, in build\_extension  
depends=ext.depends)  
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.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [November 9, 2022, 9:58pm UTC](https://discourse.mc-stan.org/t/distutils-errors-compileerror-command-c-mingw-bin-gcc-exe-failed-with-exit-status-1/28921/2 "2022-11-09T21:58:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ahartikainen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ahartikainen/32/321_2.png) [@ahartikainen](https://discourse.mc-stan.org/u/ahartikainen)\
**Post date:** [November 10, 2022, 8:00am UTC](https://discourse.mc-stan.org/t/distutils-errors-compileerror-command-c-mingw-bin-gcc-exe-failed-with-exit-status-1/28921/3 "2022-11-10T08:00:46Z")

</div>

Hi,

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

I recommend following [PyStan on Windows — PyStan 2.19.1.1 documentation](https://pystan2.readthedocs.io/en/latest/windows.html)

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

Also use python \< 3.9.
