2

我试图让 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

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

提前致谢

4

1 回答 1

0

我在 MinGW 下安装 pystan 时遇到了类似的问题,我通过

因此,如果您按照指南进行操作,则无需手动安装 MinGW,它将作为安装指南中的步骤之一安装在 Anaconda 下。

你应该总是从 Anaconda Prompt 运行你的 python 脚本。我想那是因为 Anaconda Prompt 为编译(依赖项等)正确地准备了环境,而运行 vanilla Cmd 则不会。我希望这也能解决你的问题。

于 2018-10-10T16:07:01.740 回答