Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3 ImportError: cannot import name 'model selection' OS X 10.11.3, Anaconda

Python 3.5.1 |Anaconda 4.0.0 (x86_64)on OS X 10.11.3

>>> from sklearn import pipeline, model_selection

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'model_selection'

tried to:

upgrade six, sk-learn,

sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2
pip2 install six -U
pip install --ignore-installed six
pip install --ignore-installed ipython

even reinstall the anaconda... Did NOT fixed.

Thanks for help

_________Updata________

I have checked that my six version is the newest one (version = "1.10.0")

import sklearn

sklearn.version '0.17.1'

I found that there is no folder name "model_selection" in sklearn folder. But there is this folder in https://github.com/scikit-learn/scikit-learn/tree/3078d7d611329c46777d4004a1185a3626558efe/sklearn.

After install the dev version by

$ pip install git+git://github.com/scikit-learn/scikit-learn.git

Successfully installed scikit-learn-0.18.dev0

And then run a script which runs successfully in 0.17.1, it shows error:

from .pairwise_fast import _chi2_kernel_fast, _sparse_manhattan ImportError: dlopen(/Users/Username/anaconda3/lib/python3.5/site-packages/sklearn/metrics/pairwise_fast.cpython-35m-darwin.so, 2): Library not loaded: libmkl_intel_lp64.dylib Referenced from: /Users/Username/anaconda3/lib/python3.5/site-packages/sklearn/metrics/pairwise_fast.cpython-35m-darwin.so Reason: image not found

like image 221
Qinqing Liu Avatar asked Apr 01 '16 00:04

Qinqing Liu


1 Answers

What version of scikit-learn are you using? It looks like the latest, when I install for Python 3.5, is 0.17.1. Checking in the console:

import sklearn
sklearn.__version__
'0.17.1'

According to the documentation for this version that "model_selection" package doesn't exist. It does exist in the dev version. This should be why it is complaining.

like image 75
Paul Avatar answered Nov 15 '22 06:11

Paul