CompileError:command' C:\\ MinGW \\ bin \\ gcc.exe'安装pystan时退出状态为1失败

时间:2018-05-25 14:31:33

标签: python-3.x gcc mingw facebook-prophet pystan

我试图让pystan在Windows 10上工作,以便将fbprophet包用于时间序列。我已经安装了MinGW,将其目录添加到我的PATH环境变量中并尝试使用这段代码来验证一切正常:

gcc -dumpversion
ld -v
dllwrap -version

产生这些结果:

C:\WINDOWS\system32>gcc -dumpversion
6.3.0

C:\WINDOWS\system32>ld -v
GNU ld (GNU Binutils) 2.28

C:\WINDOWS\system32>dllwrap -version
GNU dllwrap (GNU Binutils) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

到目前为止,一切顺利。

问题出现在python中,我尝试执行以下代码:

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)
y = model.sampling(n_jobs > 1).extract()['y']
y.mean()  # with luck the result will be near 0

我得到了这个输出:

import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code)
y = model.sampling(n_jobs > 1).extract()['y']
y.mean()  # with luck the result will be near 0
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_5944b02c79788fa0db5b3a93728ca2bf NOW.
Traceback (most recent call last):

  File "<ipython-input-3-941feb69c4c4>", line 3, in <module>
    model = pystan.StanModel(model_code=model_code)

  File "Z:\Anaconda3\lib\site-packages\pystan\model.py", line 313, in __init__
    build_extension.run()

  File "Z:\Anaconda3\lib\distutils\command\build_ext.py", line 339, in run
    self.build_extensions()

  File "Z:\Anaconda3\lib\distutils\command\build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()

  File "Z:\Anaconda3\lib\distutils\command\build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)

  File "Z:\Anaconda3\lib\distutils\command\build_ext.py", line 533, in build_extension
    depends=ext.depends)

  File "Z:\Anaconda3\lib\distutils\ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)

  File "Z:\Anaconda3\lib\distutils\cygwinccompiler.py", line 175, in _compile
    raise CompileError(msg)

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

我在发布此问题以及其他网站之前已在网站上搜索过,但似乎没有什么对我有用。我很感激任何帮助。

提前致谢

1 个答案:

答案 0 :(得分:0)

我在MinGW下安装pystan时遇到了类似的问题,并且通过以下方式解决了问题

因此,如果您遵循该指南,则无需手动安装MinGW,它将作为安装指南中的步骤之一安装在Anaconda下。

并且您应该始终从Anaconda Prompt运行python脚本。我猜这是因为Anaconda Prompt正确准备了运行香草Cmd不会编译的环境(依赖项等)。 我希望这也能解决您的问题。