実現したいこと
ローカル環境のjupyter notebookでprophetのライブラリを用いた解析を行いたいと考えています。
発生している問題・分からないこと
prophetをインストールし、動かそうとしたのですが、
「AttributeError: 'Prophet' object has no attribute 'stan_backend'」
とエラーが出ました。
調べると、pystanが動く環境である必要があるとのことだったので、
pystanのインストールを行ったのですが、これも上手くコンパイルできずに困っています。
どのように対処すればうまく動くようになるかご教授頂きたいです。
エラーメッセージ
error
1DistutilsExecError Traceback (most recent call last) 2D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\cygwinccompiler.py in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts) 3 144 self.spawn( 4--> 145 self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs 5 146 ) 6 7D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\ccompiler.py in spawn(self, cmd, **kwargs) 8 1006 def spawn(self, cmd, **kwargs): 9-> 1007 spawn(cmd, dry_run=self.dry_run, **kwargs) 10 1008 11 12D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\spawn.py in spawn(cmd, search_path, verbose, dry_run, env) 13 70 raise DistutilsExecError( 14---> 71 "command {!r} failed with exit code {}".format(cmd, exitcode) 15 72 ) 16 17DistutilsExecError: command 'C:\\Users\\○○○\\anaconda3\\Library\\mingw-w64\\bin\\gcc.exe' failed with exit code 1 18 19During handling of the above exception, another exception occurred: 20 21CompileError Traceback (most recent call last) 22~\AppData\Local\Temp\ipykernel_13756\1613198025.py in <module> 23 1 from pystan import StanModel 24 2 25----> 3 model = StanModel(model_code="parameters {real y;} model {y ~ normal(0,1);}") 26 4 print(model.sampling()["y"].mean()) 27 28D:\Anaconda_envs\envs\prophet_env\lib\site-packages\pystan\model.py in __init__(self, file, charset, model_name, model_code, stanc_ret, include_paths, boost_lib, eigen_lib, verbose, obfuscate_model_name, extra_compile_args, allow_undefined, include_dirs, includes) 29 376 30 377 try: 31--> 378 build_extension.run() 32 379 finally: 33 380 if redirect_stderr: 34 35D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in run(self) 36 344 37 345 # Now actually compile and link everything. 38--> 346 self.build_extensions() 39 347 40 348 def check_extensions_list(self, extensions): # noqa: C901 41 42D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in build_extensions(self) 43 466 self._build_extensions_parallel() 44 467 else: 45--> 468 self._build_extensions_serial() 46 469 47 470 def _build_extensions_parallel(self): 48 49D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in _build_extensions_serial(self) 50 492 for ext in self.extensions: 51 493 with self._filter_build_errors(ext): 52--> 494 self.build_extension(ext) 53 495 54 496 @contextlib.contextmanager 55 56D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in build_extension(self, ext) 57 554 debug=self.debug, 58 555 extra_postargs=extra_args, 59--> 556 depends=ext.depends, 60 557 ) 61 558 62 63D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\ccompiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends) 64 597 except KeyError: 65 598 continue 66--> 599 self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) 67 600 68 601 # Return *all* object filenames, not just the ones we just built. 69 70D:\Anaconda_envs\envs\prophet_env\lib\site-packages\setuptools\_distutils\cygwinccompiler.py in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts) 71 146 ) 72 147 except DistutilsExecError as msg: 73--> 148 raise CompileError(msg) 74 149 75 150 def link( 76 77CompileError: command 'C:\\Users\\○○○\\anaconda3\\Library\\mingw-w64\\bin\\gcc.exe' failed with exit code 1
該当のソースコード
Python
1from pystan import StanModel 2 3model = StanModel(model_code="parameters {real y;} model {y ~ normal(0,1);}") 4print(model.sampling()["y"].mean())
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
https://pystan2.readthedocs.io/en/latest/windows.html
https://indonegiyaland.hatenablog.com/entry/2022/03/31/162245
上記のページを参考に設定しました。
補足
仮想環境で実施しており、インストールしているライブラリは以下の通りです。
(関係あると思われるもののみ抜粋しています)
Name Version Build Channel
cython 0.29.32 py37hf2a7229_0 conda-forge
ephem 4.1.2 py37h2bbff1b_0
holidays 0.18 py37haa95532_0
libpython 2.1 py37_0
m2w64-binutils 2.25.1 5
m2w64-bzip2 1.0.6 6
m2w64-crt-git 5.0.0.4636.2595836 2
m2w64-gcc 5.3.0 6
m2w64-gcc-ada 5.3.0 6
m2w64-gcc-fortran 5.3.0 6
m2w64-gcc-libgfortran 5.3.0 6
m2w64-gcc-libs 5.3.0 7
m2w64-gcc-libs-core 5.3.0 7
m2w64-gcc-objc 5.3.0 6
m2w64-gmp 6.1.0 2
m2w64-headers-git 5.0.0.4636.c0ad18a 2
m2w64-isl 0.16.1 2
m2w64-libiconv 1.14 6
m2w64-libmangle-git 5.0.0.4509.2e5a9a2 2
m2w64-libwinpthread-git 5.0.0.4634.697f757 2
m2w64-make 4.1.2351.a80a8b8 2
m2w64-mpc 1.0.3 3
m2w64-mpfr 3.1.4 4
m2w64-pkg-config 0.29.1 2
m2w64-toolchain 5.3.0 7 msys2
m2w64-tools-git 5.0.0.4592.90b8472 2
m2w64-windows-default-manifest 6.4 3
m2w64-winpthreads-git 5.0.0.4634.697f757 2
m2w64-zlib 1.2.8 10
mkl 2020.2 256
prophet 1.0.1 py37haa95532_0
pystan 2.19.1.1 py37hac22706_0
python 3.7.16 h6244533_0
setuptools 65.6.3 py37haa95532_0
![guest](/img/icon/icnUserSample.jpg)