如何解决FB-Prophet安装时的pip依赖解析冲突错误?
问题场景
运行FB Prophet时触发依赖安装,出现holidays版本冲突:
Installing collected packages: holidays
Attempting uninstall: holidays
Found existing installation: holidays 0.21.13
Uninstalling holidays-0.21.13:
Successfully uninstalled holidays-0.21.13
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
neuralprophet 0.6.2 requires holidays<0.22,>=0.21, but you have holidays 0.42 which is incompatible.
Successfully installed holidays-0.42
WARNING: The following packages were previously imported in this runtime:
[holidays]
You must restart the runtime in order to use newly installed versions.
解决方法
方法1:安装兼容双工具的holidays版本
执行命令安装同时满足FB Prophet和NeuralProphet要求的holidays版本:
pip install holidays==0.21.13
安装完成后重启运行环境(如Jupyter内核、终端会话),确保版本生效。
方法2:用虚拟环境隔离依赖
如果需要同时使用FB Prophet和NeuralProphet,为两者分别创建独立虚拟环境:
- 为FB Prophet创建环境:
python -m venv prophet_env # Windows激活 prophet_env\Scripts\activate # Linux/macOS激活 source prophet_env/bin/activate pip install fbprophet
- 为NeuralProphet创建环境:
python -m venv neuralprophet_env # Windows激活 neuralprophet_env\Scripts\activate # Linux/macOS激活 source neuralprophet_env/bin/activate pip install neuralprophet==0.6.2
通过环境隔离彻底避免依赖冲突。
方法3:升级NeuralProphet兼容高版本holidays
检查NeuralProphet最新版本是否放宽了holidays版本限制,执行升级:
pip install --upgrade neuralprophet
升级后确认依赖兼容,再重启运行环境即可。
内容的提问来源于stack exchange,提问作者Blessy Varghese

