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

13,046

Solution 1

Install and import joblib directly:

!pip install joblib
import joblib

Solution 2

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.

Share:
13,046

Related videos on Youtube

Zia
Author by

Zia

Updated on June 04, 2022

Comments

  • Zia
    Zia almost 2 years

    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:\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'
    
  • Underoos
    Underoos about 5 years
    Providing the commands that you tried and the files that you've modified would be more helpful.