cannot import name 'joblib' from 'sklearn.externals'
时间: 2023-07-27 07:07:28 浏览: 215
This error occurs when trying to import the 'joblib' module from the 'sklearn.externals' package in Scikit-learn. This is because the 'joblib' module has been moved to a separate package starting from Scikit-learn version 0.21.
To fix this error, you need to install the 'joblib' package separately by running the following command in your terminal:
```
pip install joblib
```
Once the installation is complete, you can import the 'joblib' module directly without using the 'sklearn.externals' package:
```
from joblib import dump, load
```
This should resolve the import error you are facing.
相关问题
cannot import name 'joblib' from 'sklearn.externals
该错误提示是因为在新版本的scikit-learn中,joblib已经被移动到了sklearn库中,所以需要使用以下代码进行导入:
from sklearn import joblib
或者
import sklearn.externals.joblib as joblib
但是报错cannot import name 'joblib' from 'sklearn.externals
这个错误是因为在新版本的 scikit-learn 中,`joblib` 库不再在 `sklearn.externals` 中,而是独立成为一个包。你可以通过安装 `joblib` 包来解决这个问题。你可以使用以下命令:
```
pip install joblib
```
或者,如果你使用的是 conda 环境,则可以使用以下命令:
```
conda install joblib
```
安装完成后,你需要在代码中将 `joblib` 的导入语句修改为:
```
from joblib import dump, load
```
这样就可以解决这个问题了。
阅读全文