ModuleNotFoundError: No module named sklearn 是怎么回事
时间: 2023-10-17 17:37:59 浏览: 449
ModuleNotFoundError: No module named ‘sklearn.cross_validation’
ModuleNotFoundError: No module named 'sklearn' 是指在Python代码中引入sklearn库时出现的错误提示。具体原因是由于历史遗留原因,sklearn库已经废弃,现在需要安装的是scikit-learn。
解决这个问题的方法是先使用pip install scikit-learn命令安装scikit-learn库。安装成功后,即可使用import sklearn来引入库,不再报错。
另外,有些情况下可能还需要安装scikit-learn的依赖库,例如Numpy、Scipy、matplotlib。可以使用pip install numpy、pip install scipy、pip install matplotlib来分别安装这些依赖库。
总结来说,ModuleNotFoundError: No module named 'sklearn' 的解决方案是先安装scikit-learn库,然后再执行相关代码即可避免报错。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ModuleNotFoundError: No module named ‘sklearn‘解决方案](https://blog.csdn.net/weixin_43178406/article/details/130502547)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [ModuleNotFoundError: No module named ‘sklearn](https://blog.csdn.net/weixin_50952710/article/details/127961433)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文