• AttributeError: ‘Prophet‘ object has no attribute ‘stan_backend‘解决方案


    在使用Facebook prophet过程遇到如下问题:
    代码如下:

    from prophet import Prophet
    model = Prophet()
    
    • 1
    • 2

    执行程序报如下错误:

    	  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'
    
    • 1
    • 2
    • 3

    运行环境为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.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48

    这个错误是在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
    
    • 1
    • 2
    • 3
    • 4

    很奇怪,我的开发环境为windows 10 专业版,同样的安装环境,没有出现问题。为什么呢?
    在这里插入图片描述
    我的本机上也没有安装pyspan,也没有问题,为什么呢?欢迎反馈,谢谢!

  • 相关阅读:
    Java CountDownLatch 学习总结
    智能车电磁组元素处理(圆环、三岔、路障)
    推荐5款数据可视化强势工具
    Python机器学习笔记:CART算法实战
    基于javaweb软件专业介绍管理系统
    J. 金色传说【10.14训练补题】
    代码随想录打卡第六十三天|84.柱状图中最大的矩形
    网络安全基础技术扫盲篇 — 名词解释之“数据包“
    【STM32】CRC(循环冗余校验)
    ES 模块语法改为 CommonJS 模块语法的区别
  • 原文地址:https://blog.csdn.net/xiaoyw/article/details/133314057