基于Python实现时间序列分析建模(ARIMA模型)项目实战

fbprophet最新版0.7.1 怎么安装

fbprophet怎么使用fbprophet预测模型

报错

E:\pycharm\anaconda\envs\py37\python.exe F:\Merchant\merchant202502\Prophet\prophet.py
Traceback (most recent call last):
File "F:\Merchant\merchant202502\Prophet\prophet.py", line 30, in <module>
from fbprophet import Prophet
File "E:\pycharm\anaconda\envs\py37\lib\site-packages\fbprophet_init_.py", line 8, in <module>
from fbprophet.forecaster import Prophet
File "E:\pycharm\anaconda\envs\py37\lib\site-packages\fbprophet\forecaster.py", line 17, in <module>
from fbprophet.make_holidays import get_holiday_names, make_holidays_df
File "E:\pycharm\anaconda\envs\py37\lib\site-packages\fbprophet\make_holidays.py", line 14, in <module>
import fbprophet.hdays as hdays_part2
File "E:\pycharm\anaconda\envs\py37\lib\site-packages\fbprophet\hdays.py", line 924, in <module>
class TU(Turkey):
File "E:\pycharm\anaconda\envs\py37\lib\site-packages\holidays\registry.py", line 182, in init
"This is a python-holidays entity loader class. "
TypeError: This is a python-holidays entity loader class. For entity inheritance purposes please import a class you want to derive from directly: e.g., from holidays.countries import Entity or from holidays.financial import Entity.

Process finished with exit code 1

解决方案

python 3.7
fbprophet == 0.7.1
Check for holidays dependency conflict:
The issue may also arise if there is a conflict between the holidays version installed and the one expected by fbprophet. You can try downgrading holidays to a version that works well with fbprophet, e.g., version 0.10.3:

bash
pip install holidays==0.10.3

这个错误的根本原因是 fbprophetholidays 库的兼容性问题,特别是 fbprophet 在加载节假日信息时遇到了 holidays 库的类继承问题。

错误信息提到 holidays 类需要通过直接导入具体的类来继承,而不是使用默认的实体加载器类(Entity),这导致了 TypeError

更新 holidays 库到最新版本

问题出现在 holidays 库中,确保该库是最新版本。

bash
pip install --upgrade holidays

确保你的 holidays 版本是兼容的。你可以查看 holidays 的文档,确保所使用的版本没有已知的兼容性问题。

Check for holidays dependency conflict: The issue may also arise if there is a conflict between the holidays version installed and the one expected by fbprophet. You can try downgrading holidays to a version that works well with fbprophet, e.g., version 0.10.3