以下の条件でpystanを回したらエラーが出てしまい、解決方法を知りたいです。
プログラミング初心者で素人質問で恐縮ですがよろしくお願い致します。
・M1Macを使用
・Anaconda Navigatorからjupyter notebookを使用
コード
import pystan
import matplotlib.pyplot as plt
import numpy as np
OneVar_code = """
data {
int<lower=0> J;
real y[J];
}
parameters {
real<lower=-1000, upper=1000> mu;
real<lower=0, upper=1000> sigma;
}
transformed parameters {
}
model {
y ~ normal(mu, sigma);
}
"""
LData = [ 44, 44, 56, 59, 44, 44, 63, 60, 34, 58,
55, 50, 32, 61, 47, 25, 38, 47, 30, 42]
OneVar_dat = { 'J' : len(LData), 'y': LData }
sm = pystan.StanModel(model_code=OneVar_code)
fit = sm.sampling(data=OneVar_dat, iter=5000, chains=4, n_jobs=1)
print(fit)
エラー内容
FileNotFoundError Traceback (most recent call last)
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/spawn.py:57, in spawn(cmd, search_path, verbose, dry_run, env)
56 try:
---> 57 proc = subprocess.Popen(cmd, env=env)
58 proc.wait()
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/subprocess.py:951, in Popen.init(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask)
948 self.stderr = io.TextIOWrapper(self.stderr,
949 encoding=encoding, errors=errors)
--> 951 self._execute_child(args, executable, preexec_fn, close_fds,
952 pass_fds, cwd, env,
953 startupinfo, creationflags, shell,
954 p2cread, p2cwrite,
955 c2pread, c2pwrite,
956 errread, errwrite,
957 restore_signals,
958 gid, gids, uid, umask,
959 start_new_session)
960 except:
961 # Cleanup if the child failed starting.
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/subprocess.py:1821, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)
1820 err_msg = os.strerror(errno_num)
-> 1821 raise child_exception_type(errno_num, err_msg, err_filename)
1822 raise child_exception_type(err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'gcc-9'
The above exception was the direct cause of the following exception:
DistutilsExecError Traceback (most recent call last)
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py:186, in UnixCCompiler._compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
185 try:
--> 186 self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
187 except DistutilsExecError as msg:
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py:1007, in CCompiler.spawn(self, cmd, **kwargs)
1006 def spawn(self, cmd, **kwargs):
-> 1007 spawn(cmd, dry_run=self.dry_run, **kwargs)
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/spawn.py:63, in spawn(cmd, search_path, verbose, dry_run, env)
62 cmd = cmd[0]
---> 63 raise DistutilsExecError(
64 "command {!r} failed: {}".format(cmd, exc.args[-1])
65 ) from exc
67 if exitcode:
DistutilsExecError: command 'gcc-9' failed: No such file or directory
During handling of the above exception, another exception occurred:
CompileError Traceback (most recent call last)
Cell In[24], line 51
41 LData = [ 44, 44, 56, 59, 44, 44, 63, 60, 34, 58,
42
43 55, 50, 32, 61, 47, 25, 38, 47, 30, 42]
47 OneVar_dat = { 'J' : len(LData), 'y': LData }
---> 51 sm = pystan.StanModel(model_code=OneVar_code)
53 fit = sm.sampling(data=OneVar_dat, iter=5000, chains=4, n_jobs=1)
57 print(fit)
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/pystan/model.py:378, in StanModel.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)
375 orig_stderr = pystan.misc._redirect_stderr()
377 try:
--> 378 build_extension.run()
379 finally:
380 if redirect_stderr:
381 # restore stderr
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py:346, in build_ext.run(self)
343 self.compiler.set_link_objects(self.link_objects)
345 # Now actually compile and link everything.
--> 346 self.build_extensions()
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py:468, in build_ext.build_extensions(self)
466 self._build_extensions_parallel()
467 else:
--> 468 self._build_extensions_serial()
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py:494, in build_ext._build_extensions_serial(self)
492 for ext in self.extensions:
493 with self._filter_build_errors(ext):
--> 494 self.build_extension(ext)
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py:549, in build_ext.build_extension(self, ext)
546 for undef in ext.undef_macros:
547 macros.append((undef,))
--> 549 objects = self.compiler.compile(
550 sources,
551 output_dir=self.build_temp,
552 macros=macros,
553 include_dirs=ext.include_dirs,
554 debug=self.debug,
555 extra_postargs=extra_args,
556 depends=ext.depends,
557 )
559 # XXX outdated variable, kept here in case third-part code
560 # needs it.
561 self._built_objects = objects[:]
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py:599, in CCompiler.compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
597 except KeyError:
598 continue
--> 599 self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
601 # Return all object filenames, not just the ones we just built.
602 return objects
File ~/opt/anaconda3/envs/MyEnvitonment/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py:188, in UnixCCompiler._compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
186 self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
187 except DistutilsExecError as msg:
--> 188 raise CompileError(msg)
CompileError: command 'gcc-9' failed: No such file or directory
あなたの回答
tips
プレビュー