一、報錯
from sklearn.utils.validation import check_memory
ImportError: cannot import name 'check_memory'
二、解決
1.首先我去看了相關位置的源碼
發現validation.py裏面確實沒有check_memory方法,我的sklearn版本爲0.19
2.去官網搜索相關模塊信息
https://scikit-learn.org/stable/modules/classes.html
點擊第一個,然後點擊source去看最新源碼
我發現最新版本0.22中是有該方法的,所以解決方案就是更新sklearn
3.更新sklearn
首先嚐試
conda update scikit-learn
但是沒有最新的源,還是給我安裝了0.19;所以進行本地安裝
(1)先去下載需要的版本
https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn
(2)在本地運行以下命令
先刪除原本的
conda remove scikit-learn
再安裝(E:\Install\scikit_learn-0.22.2.post1-cp35-cp35m-win_amd64.whl 這個是我下載後的本地路徑)
pip install E:\Install\scikit_learn-0.22.2.post1-cp35-cp35m-win_amd64.whl
然後就大功告成了~
參考了以下文章
http://www.shujuren.org/article/725.html
https://blog.csdn.net/j18233653274/article/details/89847011