How would someone go about building it from source? Is there a script we can follow? Thanks very much!
I have been trying to install pystan==2.19
on MacM1. Here is my environment:
conda create -n stan2 python=3.7 --yes
conda activate stan2
conda install -c anaconda clang_osx-64 clangxx_osx-64 --yes
conda install -c conda-forge numpy pandas scipy cython ipython jupyterlab matplotlib freetype --yes
python -m pip install --upgrade pip
pip install pystan==2.19.0.0
conda install -c conda-forge arviz --yes
python -c "import pystan; import arviz"
But I get the following error when running the 8 schools code here
When running this line sm = pystan.StanModel(model_code=schools_code)
on M1 Mac:
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_19a09b474d1901f191444eaf8a6b8ce2 NOW.
---------------------------------------------------------------------------
DistutilsExecError Traceback (most recent call last)
~/miniconda3/envs/stan2/lib/python3.7/distutils/unixccompiler.py in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
117 self.spawn(compiler_so + cc_args + [src, '-o', obj] +
--> 118 extra_postargs)
119 except DistutilsExecError as msg:
~/miniconda3/envs/stan2/lib/python3.7/distutils/ccompiler.py in spawn(self, cmd)
909 def spawn(self, cmd):
--> 910 spawn(cmd, dry_run=self.dry_run)
911
~/miniconda3/envs/stan2/lib/python3.7/distutils/spawn.py in spawn(cmd, search_path, verbose, dry_run)
35 if os.name == 'posix':
---> 36 _spawn_posix(cmd, search_path, dry_run=dry_run)
37 elif os.name == 'nt':
~/miniconda3/envs/stan2/lib/python3.7/distutils/spawn.py in _spawn_posix(cmd, search_path, verbose, dry_run)
158 "command %r failed with exit status %d"
--> 159 % (cmd, exit_status))
160 elif os.WIFSTOPPED(status):
DistutilsExecError: command 'x86_64-apple-darwin13.4.0-clang' failed with exit status 254
During handling of the above exception, another exception occurred:
CompileError Traceback (most recent call last)
<ipython-input-2-25aa85272b50> in <module>
24 'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}
25
---> 26 sm = pystan.StanModel(model_code=schools_code)
27 fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
~/miniconda3/envs/stan2/lib/python3.7/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)
347
348 try:
--> 349 build_extension.run()
350 finally:
351 if redirect_stderr:
~/miniconda3/envs/stan2/lib/python3.7/distutils/command/build_ext.py in run(self)
338
339 # Now actually compile and link everything.
--> 340 self.build_extensions()
341
342 def check_extensions_list(self, extensions):
~/miniconda3/envs/stan2/lib/python3.7/distutils/command/build_ext.py in build_extensions(self)
447 self._build_extensions_parallel()
448 else:
--> 449 self._build_extensions_serial()
450
451 def _build_extensions_parallel(self):
~/miniconda3/envs/stan2/lib/python3.7/distutils/command/build_ext.py in _build_extensions_serial(self)
472 for ext in self.extensions:
473 with self._filter_build_errors(ext):
--> 474 self.build_extension(ext)
475
476 @contextlib.contextmanager
~/miniconda3/envs/stan2/lib/python3.7/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
~/miniconda3/envs/stan2/lib/python3.7/distutils/ccompiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
572 except KeyError:
573 continue
--> 574 self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
575
576 # Return *all* object filenames, not just the ones we just built.
~/miniconda3/envs/stan2/lib/python3.7/distutils/unixccompiler.py in _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
118 extra_postargs)
119 except DistutilsExecError as msg:
--> 120 raise CompileError(msg)
121
122 def create_static_lib(self, objects, output_libname,
CompileError: command 'x86_64-apple-darwin13.4.0-clang' failed with exit status 254
Which makes sense to me: the C++ bits are made for an Intel x86 architecture, but the Mac has an M1 chip (very imprecise language because that is all I understand).
Is there a solution? Not to worry if not, I can get Pystan3 working with this environment in my gist here
The reason I was hoping to also install Pystan2 was that I am attending a course with the materials in Pystan2. Worst case scenario I can
(i) do the translation exercise into Pystan3
(ii) run a Linux Virtual Machine somewhere and install the environment from here
this may have something to do with it. The following message after running conda install -c anaconda clang_osx-64 clangxx_osx-64 --yes
objc[16431]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1e99eb678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1042202c8). One of the two will be used. Which one is undefined.
objc[16431]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1e99eb6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x104220318). One of the two will be used. Which one is undefined.
objc[16437]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1e99eb678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10442c2c8). One of the two will be used. Which one is undefined.
objc[16437]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1e99eb6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10442c318). One of the two will be used. Which one is undefined.