我试图让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
我在发布此问题之前在网站上搜索过,以及在其他网站上搜索过,但似乎没有什么对我有用。我很感激任何帮助。
提前致谢
我在MinGW下安装pystan有类似的问题,我解决了它
因此,如果您按照指南操作,则无需手动安装MinGW,它将作为安装指南中的一个步骤安装在Anaconda下。
而且你应该总是从Anaconda Prompt运行你的python脚本。我想这是因为Anaconda Prompt正在准备环境以便正确编译(依赖项等)哪个运行vanilla Cmd不会。我希望这也能解决你的问题。