在使用Facebook prophet过程遇到如下问题:
代码如下:
from prophet import Prophet
model = Prophet()
执行程序报如下错误:
File "D:\Python\Python38\lib\site-packages\prophet\forecaster.py", line 156, in _load_stan_backend
logger.debug("Loaded stan backend: %s", self.stan_backend.get_type())
AttributeError: 'Prophet' object has no attribute 'stan_backend'
运行环境为windows server 2019,python3.8。
Package Version
------------------- ----------
APScheduler 3.10.1
backports.zoneinfo 0.2.1
certifi 2023.5.7
charset-normalizer 2.0.12
cmdstanpy 1.1.0
colorama 0.4.6
convertdate 2.4.0
cycler 0.11.0
ephem 4.1.4
greenlet 2.0.2
h5py 3.8.0
holidays 0.28
idna 3.4
imageio 2.31.1
importlib-metadata 4.11.3
importlib-resources 5.12.0
joblib 1.1.0
kiwisolver 1.4.4
loguru 0.7.0
LunarCalendar 0.0.9
matplotlib 3.4.3
networkx 3.1
numpy 1.22.4+mkl
packaging 23.1
pandas 1.4.3
Pillow 8.4.0
pip 21.1.1
prophet 1.1.4
PyMeeus 0.5.12
pyparsing 3.1.0
python-dateutil 2.8.2
pytz 2022.1
PyWavelets 1.4.1
scikit-image 0.19.2
scikit-learn 1.1.1
scipy 1.7.3
setuptools 56.0.0
six 1.16.0
threadpoolctl 3.1.0
tifffile 2023.7.4
tqdm 4.65.0
tzdata 2023.3
tzlocal 5.0.1
urllib3 1.26.16
win32-setctime 1.1.0
zipp 3.15.
这个错误是在python中,facebook prophet对象没有“stan_backend”属性,通常是由于在安装prophet时,没有正确安装stan后端引起的。解决方案是安装pystan:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pystan==2.19.1.1
我的操作是先卸载:cmdstanpy、prophet:
pip uninstall cmdstanpy
pip uninstall prophet
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pystan==2.19.1.1
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple prophet
参考:https://github.com/facebook/prophet/issues/1835
Just adding my two cents to this issue:
The documentation mentions that we need to install a specific version of PyStan, so be mindful of this.
pip install pystan==2.19.1.1
After installing this it started working for me
很奇怪,我的开发环境为windows 10 专业版,同样的安装环境,没有出现问题。为什么呢?
我的本机上也没有安装pyspan,也没有问题,为什么呢?欢迎反馈,谢谢!