Winston Robson
1 min readMar 24, 2021

--

KeyError Traceback (most recent call last)KeyError: 'metric_file'Exception ignored in: 'stanfit4anon_model_f5236004a3fd5b8429270d00efcc0cf9_9045703871880297330._set_stanargs_from_dict'Traceback (most recent call last):File "C:\ProgramData\Anaconda3\lib\site-packages\pystan\model.py", line 550, in optimizingret, sample = fit._call_sampler(stan_args)KeyError: 'metric_file'

Based on the references to ‘stan’, I'm guessing the issue is with Stan, which does the math for Prophet.

Someone posted an issue in the prophet repo here: https://github.com/facebook/prophet/issues/1670

I found that issue by googling “keyerror: ‘metric_file' pystan".

It looks like a few people have found temporary solutions or workarounds that may be worth checking out.

Installing Stan

Installing Stan as described in the docs has always worked for me: https://pystan.readthedocs.io/en/latest/installation.html but I’ve always been on Mac, Ubuntu, or using the R API instead of Python.

If you're on Windows, it looks like you might be out of luck: Microsoft Windows is not supported in PyStan 3. It was (partially) supported in PyStan 2. <- https://pystan.readthedocs.io/en/latest/upgrading.html

Note: it looked like some people talking in issue#1670 were able to just use PyStan 2.

Other

Working through errors can be a pain (I’m taking a break from doing it right now actually), but if you make a practice of going though, line-by-line on short errors like this you’ll easily understand them in no time. I believe in you.

Hope this helps! Thanks for reading. — W

--

--