Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

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

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

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

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

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:Anaconda3libsite-packagessklearndecomposition\__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:Anaconda3libsite-packagessklearndecompositionsparse_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:Anaconda3libsite-packagessklearndecompositiondict_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'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This comment on a PR in May 2019 mentions that they wanted to ditch it.

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...