質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Anaconda

Anacondaは、Python本体とPythonで利用されるライブラリを一括でインストールできるパッケージです。環境構築が容易になるため、Python開発者間ではよく利用されており、商用目的としても利用できます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

2回答

4905閲覧

AnacondaでPystanを使おうと思ったらエラーが起きました

villas

総合スコア14

Anaconda

Anacondaは、Python本体とPythonで利用されるライブラリを一括でインストールできるパッケージです。環境構築が容易になるため、Python開発者間ではよく利用されており、商用目的としても利用できます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2022/02/19 12:00

環境
Anaconda 4.11.0
Python 3.9.10
Visual Studio Build Tools 2019 C++によるデスクトップ開発インストール済
この条件で

https://pystan2.readthedocs.io/en/latest/windows.html
にある手順の通りやってみたら

1

1import pystan

はできたのですが

2

1model_code = 'parameters {real y;} model {y ~ normal(0,1);}' 2model = pystan.StanModel(model_code=model_code)

で以下のようなエラーが起こりました

INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_5944b02c79788fa0db5b3a93728ca2bf NOW. WARNING:pystan:MSVC compiler is not supported --------------------------------------------------------------------------- DistutilsExecError Traceback (most recent call last) ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\_msvccompiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends) 411 try: --> 412 self.spawn(args) 413 except DistutilsExecError as msg: ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\_msvccompiler.py in spawn(self, cmd) 516 with self._fallback_spawn(cmd, env) as fallback: --> 517 return super().spawn(cmd, env=env) 518 return fallback.value ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\ccompiler.py in spawn(self, cmd, **kwargs) 916 def spawn(self, cmd, **kwargs): --> 917 spawn(cmd, dry_run=self.dry_run, **kwargs) 918 ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\spawn.py in spawn(cmd, search_path, verbose, dry_run, env) 68 raise DistutilsExecError( ---> 69 "command %r failed with exit code %s" % (cmd, exitcode)) 70 DistutilsExecError: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 During handling of the above exception, another exception occurred: CompileError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_2012\2043026653.py in <module> 1 model_code = 'parameters {real y;} model {y ~ normal(0,1);}' ----> 2 model = pystan.StanModel(model_code=model_code) ~\anaconda3\envs\stan_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) 376 377 try: --> 378 build_extension.run() 379 finally: 380 if redirect_stderr: ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in run(self) 337 338 # Now actually compile and link everything. --> 339 self.build_extensions() 340 341 def check_extensions_list(self, extensions): ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in build_extensions(self) 446 self._build_extensions_parallel() 447 else: --> 448 self._build_extensions_serial() 449 450 def _build_extensions_parallel(self): ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in _build_extensions_serial(self) 471 for ext in self.extensions: 472 with self._filter_build_errors(ext): --> 473 self.build_extension(ext) 474 475 @contextlib.contextmanager ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\command\build_ext.py in build_extension(self, ext) 532 debug=self.debug, 533 extra_postargs=extra_args, --> 534 depends=ext.depends) 535 536 # XXX outdated variable, kept here in case third-part code ~\anaconda3\envs\stan_env\lib\site-packages\setuptools\_distutils\_msvccompiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends) 412 self.spawn(args) 413 except DistutilsExecError as msg: --> 414 raise CompileError(msg) 415 416 return objects CompileError: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

対処法を教えて頂ければ幸いです

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

エラーの原因でありそうなアプリをアンインストールしてもう一度やり直してみたら出来ました。
なぜエラーが発生したのかは分からずじまいですが。

投稿2022/02/20 11:22

編集2022/02/20 11:23
villas

総合スコア14

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kapi0817

2023/04/30 02:06

私も同様のエラーが出ているのですが、上記の場合はどのアプリをアンインストールしたのでしょうか?またそのアプリは再度インストールされたのでしょうか? 可能であれば教えていただけると幸いです。
guest

0

PyStan on Windows に以下のように書かれています。

Due to problems with MSVC template deduction, functions with Eigen library are failing. Until this and other bugs are fixed no support is provided for Windows + MSVC. Currently, no fix is known for this problem, other than to change the compiler to GCC or clang-cl.

日本語訳

以下のサイトを参考にしてやってみてください。

Windows の Anaconda 環境に PyStan をインストールする方法

投稿2022/02/19 12:36

ppaul

総合スコア24666

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

villas

2022/02/19 13:47

回答ありがとうございます 紹介させてもらったサイトの手順通りやってみましたが上記と同じエラーが発生しました やはりバージョンの違いとかの問題なのでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問