简体   繁体   中英

ModuleNotFoundError: No module named 'sklearn.compose'

I am trying to import this

from sklearn.compose import ColumnTransformer

but getting the error:

ModuleNotFoundError: No module named 'sklearn.compose'

My scikit-learn package version is 0.19.1 in anaconda.

sklearn.compose is not available in scikit-learn v0.19; it was introduced in v0.20. From the docs :

New in version 0.20.

You can also confirm from the list of modules for v0.19 that there is not a sklearn.compose module.

You should upgrade to the latest scikit-learn version (currently 0.20.3) by running

conda install -c conda-forge scikit-learn

from your command prompt (see the package page at Anaconda cloud or the SO thread How to upgrade scikit-learn package in anaconda for more options).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM