You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从fbprophet包导入holidays时报错求助(版本0.7.1)

解决fbprophet 0.7.1导入holidays模块间歇性TypeError问题

问题根源

fbprophet 0.7.1对python-holidays的版本依赖范围较宽松,当环境中安装的python-holidays版本过高(≥0.20)时,其内部实体加载逻辑发生了变更,而旧版fbprophet的代码未适配该变化,从而间歇性触发导入错误。

可行解决办法

  • 锁定兼容的python-holidays版本:安装与fbprophet 0.7.1匹配的python-holidays版本,推荐锁定在0.19.0及以下。执行命令:
    pip install holidays==0.19.0
    
    若使用requirements.txt管理依赖,添加一行:
    holidays<=0.19.0
    
  • 替换导入逻辑:如果无法降级python-holidays,直接绕过fbprophet的中间导入层,从python-holidays的官方路径导入所需实体,示例:
    from holidays.countries import China  # 按需替换为你需要的国家/地区实体
    # 若要兼容原有代码,可做简单映射
    hdays_part2 = __import__('holidays')
    
  • 清理缓存重装依赖:缓存的旧模块可能导致间歇性异常,执行以下命令清理并重新安装:
    pip cache purge
    pip uninstall -y fbprophet holidays
    pip install fbprophet==0.7.1 holidays==0.19.0
    

内容的提问来源于stack exchange,提问作者Sarang Manjrekar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 22:47:01