使用pip安装bnlearn库时出现subprocess-exited-with-error错误求助
解决pip install bnlearn时的sklearn弃用报错
报错信息
Collecting bnlearnNote: you may need to restart the kernel to use updated packages. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [15 lines of output] The 'sklearn' PyPI package is deprecated, use 'scikit-learn' rather than 'sklearn' for pip commands. note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error ... │ exit code: 1 ╰─> See above for output.
问题原因
sklearn PyPI包已被官方弃用,官方明确要求使用scikit-learn作为包名执行pip命令。bnlearn的构建依赖中仍引用了旧的sklearn包名,导致构建wheel时失败。
解决方案
方法1:先安装官方包再安装bnlearn
- 手动安装官方支持的
scikit-learn包:
pip install scikit-learn
- 重新执行bnlearn安装命令:
pip install bnlearn
方法2:强制替换依赖包名
如果方法1无效,可直接在安装bnlearn时指定替换弃用的包:
pip install bnlearn --replace-packages sklearn=scikit-learn
内容的提问来源于stack exchange,提问作者james kam
相关产品推荐
相关产品推荐

