本文介绍了ModuleNotFoundError:没有名为"sklearn.utils._joblib"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Anaconda Jupyter笔记本平台上使用python 3.6.我的电脑使用win 8.1作为操作系统.

I'm using python 3.6 on on Anaconda Jupyter notebooks platform. My pc uses win 8.1 as OS.

我正尝试使用以下几行从sklearn导入PCA:

I was trying to import PCA from sklearn using the following lines:

import sklearn
from sklearn import decomposition 
from sklearn.decomposition import PCA 

第三行返回模块错误:ModuleNotFoundError: No module named 'sklearn.utils._joblib'

the third line returns a Module error: ModuleNotFoundError: No module named 'sklearn.utils._joblib'

奇怪的是,我找不到此错误的任何记录在线!我将不胜感激.我在下面复制了完整的错误消息:

Strangely, I couldn't find any record on this error online! I'd appreciate any help. I copied the complete error message below:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-375-2e95ea83a366> in <module>()
      1 import sklearn
----> 2 from sklearn import decomposition
      3 from sklearn.decomposition import PCA
      4 # Make an instance of the Model
      5 pca = PCA(.95)

E:\Anaconda3\lib\site-packages\sklearn\decomposition\__init__.py in <module>()
      9 from .incremental_pca import IncrementalPCA
     10 from .kernel_pca import KernelPCA
---> 11 from .sparse_pca import SparsePCA, MiniBatchSparsePCA
     12 from .truncated_svd import TruncatedSVD
     13 from .fastica_ import FastICA, fastica

E:\Anaconda3\lib\site-packages\sklearn\decomposition\sparse_pca.py in <module>()
     11 from ..linear_model import ridge_regression
     12 from ..base import BaseEstimator, TransformerMixin
---> 13 from .dict_learning import dict_learning, dict_learning_online
     14 
     15 

E:\Anaconda3\lib\site-packages\sklearn\decomposition\dict_learning.py in <module>()
     15 
     16 from ..base import BaseEstimator, TransformerMixin
---> 17 from ..utils._joblib import Parallel, delayed, effective_n_jobs
     18 from ..externals.six.moves import zip
     19 from ..utils import (check_array, check_random_state, gen_even_slices,

ModuleNotFoundError: No module named 'sklearn.utils._joblib'

推荐答案

2019年5月对PR的评论提到他们想抛弃它.

从2019年6月开始, sklearn.utils._joblib不再是一个东西.

As of June 2019, sklearn.utils._joblib is no longer a thing.

  • 很难说为什么此代码在三月份无法使用,因为它仍然是支持 May 版本

分析:您的环境中有旧版本.也许pip install -r requirements.txt让您满意,超越了工作版本,还是其他的东西.

Analysis: you've got old versions in your environment. Perhaps pip install -r requirements.txt got you, overriding the working version, or something else.

建议:创建一个新的conda环境,在该环境中重新安装sklearn和joblib(通过conda install scikit-learn joblib)并继续前进.

Recommendation: make a new conda environment, reinstall sklearn and joblib (via conda install scikit-learn joblib) in that environment and move forward.

这篇关于ModuleNotFoundError:没有名为"sklearn.utils._joblib"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 07:25