Error - DistutilsPlatformError: Unable to find vcvarsall.bat

Hello. I’m new to pystan compared to pymc3. I’m getting the following error when trying to fit a pystan model. I’m attending a STAN conference in June to learn how to use STAN and i’m trying to get this to work. Any suggestions on how to fix this?


DistutilsPlatformError Traceback (most recent call last)
in
2
3 # Compile the model
----> 4 sm = pystan.StanModel(model_code=model)
5
6 # Train the model and generate samples

C:\ProgramData\Anaconda3\lib\site-packages\pystan\model.py in init(self, file, charset, model_name, model_code, stanc_ret, boost_lib, eigen_lib, verbose, obfuscate_model_name, extra_compile_args)
311
312 try:
→ 313 build_extension.run()
314 finally:
315 if redirect_stderr:

C:\ProgramData\Anaconda3\lib\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):

C:\ProgramData\Anaconda3\lib\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):

C:\ProgramData\Anaconda3\lib\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

C:\ProgramData\Anaconda3\lib\distutils\command\build_ext.py in build_extension(self, ext)
531 debug=self.debug,
532 extra_postargs=extra_args,
→ 533 depends=ext.depends)
534
535 # XXX outdated variable, kept here in case third-part code

C:\ProgramData\Anaconda3\lib\distutils_msvccompiler.py in compile(self, sources, output_dir, macros, include_dirs, debug, extra_preargs, extra_postargs, depends)
343
344 if not self.initialized:
→ 345 self.initialize()
346 compile_info = self._setup_compile(output_dir, macros, include_dirs,
347 sources, depends, extra_postargs)

C:\ProgramData\Anaconda3\lib\distutils_msvccompiler.py in initialize(self, plat_name)
236 plat_spec = PLAT_TO_VCVARS[plat_name]
237
→ 238 vc_env = _get_vc_env(plat_spec)
239 if not vc_env:
240 raise DistutilsPlatformError("Unable to find a compatible "

C:\ProgramData\Anaconda3\lib\distutils_msvccompiler.py in _get_vc_env(plat_spec)
132 vcvarsall, vcruntime = _find_vcvarsall(plat_spec)
133 if not vcvarsall:
→ 134 raise DistutilsPlatformError(“Unable to find vcvarsall.bat”)
135
136 try:

DistutilsPlatformError: Unable to find vcvarsall.bat

Hi, have you followed our Windows instructions? Remember to install libpython too.

https://pystan.readthedocs.io/en/latest/windows.html

That was it! Thank you.