ImportError: cannot import name 'joblib'

十点数据 3月前 ⋅ 232 阅读

错误信息如下:

Traceback (most recent call last):
	File "E:\WorkSpace_SaaS_WeChat\KerasBert\src\word2vec_analysis.py", line 8, in <module>
	from sklearn.externals import joblib
ImportError: cannot import name 'joblib'

from sklearn.externals import joblib ImportError: cannot import name ‘joblib‘

pip install Scikit-learn==0.20.4

from sklearn.externals import joblib ImportError: cannot import name ‘joblib’

在机器学习中,有时需要保存或加载模型,就会引入from sklearn.externals import joblib。但是大多数参考的文章时间太久,而sklearn.externals.joblib在0.21中已弃用,在0.23中被删除。故因为scikit-learn版本问题,运行时会出现报错:from sklearn.externals import joblib ImportError: cannot import name 'joblib

解决方法:

1.卸载安装的 sklearn scikit-learn joblib

pip uninstall joblib scikit-leran sklearn

2.重新安装scikit-learn,我安装的版本是0.20.4

pip install Scikit-learn==0.20.4

全部评论: 0

    我有话说: