python - Can't import 'datasets' with scikit-learn -


i installed python (tried both 3.5.2 , 2.7.12 exact same result). i've tried googling , looking through issues can't find on it.

the code i'm trying run beginning of basic tutorial:

from sklearn import datasets iris = datasets.load_iris() digits = datasets.load_digits() 

the error importerror: cannot import name 'datasets'.

i've tried re-installing everything. same result on , on again. i'm on macbook el capitan newly installed well.

i installed python pyenv, , scipy , numpy through pip. i've upgraded pip, way, latest version.

import _frozen_importlib # frozen import _imp # builtin import sys # builtin import '_warnings' # <class '_frozen_importlib.builtinimporter'> import '_thread' # <class '_frozen_importlib.builtinimporter'> import '_weakref' # <class '_frozen_importlib.builtinimporter'> import '_frozen_importlib_external' # <class '_frozen_importlib.frozenimporter'> import '_io' # <class '_frozen_importlib.builtinimporter'> import 'marshal' # <class '_frozen_importlib.builtinimporter'> import 'posix' # <class '_frozen_importlib.builtinimporter'> import _thread # loaded ('_thread') import '_thread' # <class '_frozen_importlib.builtinimporter'> import _weakref # loaded ('_weakref') import '_weakref' # <class '_frozen_importlib.builtinimporter'> # installing zipimport hook import 'zipimport' # <class '_frozen_importlib.builtinimporter'> # installed zipimport hook # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/__init__.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__init__.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/__init__.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/codecs.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/codecs.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/codecs.cpython-35.pyc' import '_codecs' # <class '_frozen_importlib.builtinimporter'> import 'codecs' # <_frozen_importlib_external.sourcefileloader object @ 0x108ac7390> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/aliases.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/aliases.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/aliases.cpython-35.pyc' import 'encodings.aliases' # <_frozen_importlib_external.sourcefileloader object @ 0x108af7f60> import 'encodings' # <_frozen_importlib_external.sourcefileloader object @ 0x108ac0f60> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/utf_8.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/utf_8.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/utf_8.cpython-35.pyc' import 'encodings.utf_8' # <_frozen_importlib_external.sourcefileloader object @ 0x108b07d30> import '_signal' # <class '_frozen_importlib.builtinimporter'> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/latin_1.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/latin_1.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/encodings/__pycache__/latin_1.cpython-35.pyc' import 'encodings.latin_1' # <_frozen_importlib_external.sourcefileloader object @ 0x108af97f0> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/io.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/io.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/io.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/abc.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/abc.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/abc.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/_weakrefset.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_weakrefset.cpython-35.pyc' import '_weakrefset' # <_frozen_importlib_external.sourcefileloader object @ 0x108b10470> import 'abc' # <_frozen_importlib_external.sourcefileloader object @ 0x108af9c50> import 'io' # <_frozen_importlib_external.sourcefileloader object @ 0x108af99e8> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/site.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/site.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/site.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/os.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/os.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/os.cpython-35.pyc' import 'errno' # <class '_frozen_importlib.builtinimporter'> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/stat.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/stat.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/stat.cpython-35.pyc' import '_stat' # <class '_frozen_importlib.builtinimporter'> import 'stat' # <_frozen_importlib_external.sourcefileloader object @ 0x108b954a8> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/posixpath.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/posixpath.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/posixpath.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/genericpath.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/genericpath.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/genericpath.cpython-35.pyc' import 'genericpath' # <_frozen_importlib_external.sourcefileloader object @ 0x108b97d30> import 'posixpath' # <_frozen_importlib_external.sourcefileloader object @ 0x108b957f0> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/_collections_abc.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_collections_abc.cpython-35.pyc' import '_collections_abc' # <_frozen_importlib_external.sourcefileloader object @ 0x108ba03c8> import 'os' # <_frozen_importlib_external.sourcefileloader object @ 0x108b24278> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_sitebuiltins.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/_sitebuiltins.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_sitebuiltins.cpython-35.pyc' import '_sitebuiltins' # <_frozen_importlib_external.sourcefileloader object @ 0x108b24550> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sysconfig.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/sysconfig.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sysconfig.cpython-35.pyc' import 'sysconfig' # <_frozen_importlib_external.sourcefileloader object @ 0x108bd9668> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/_sysconfigdata.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_sysconfigdata.cpython-35.pyc' import '_sysconfigdata' # <_frozen_importlib_external.sourcefileloader object @ 0x108bdff28> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_osx_support.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/_osx_support.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_osx_support.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/re.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/re.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/re.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sre_compile.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/sre_compile.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sre_compile.cpython-35.pyc' import '_sre' # <class '_frozen_importlib.builtinimporter'> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sre_parse.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/sre_parse.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sre_parse.cpython-35.pyc' # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sre_constants.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/sre_constants.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/sre_constants.cpython-35.pyc' import 'sre_constants' # <_frozen_importlib_external.sourcefileloader object @ 0x108c0a6a0> import 'sre_parse' # <_frozen_importlib_external.sourcefileloader object @ 0x108bfed68> import 'sre_compile' # <_frozen_importlib_external.sourcefileloader object @ 0x108bf5da0> import '_locale' # <class '_frozen_importlib.builtinimporter'> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/copyreg.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/copyreg.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/copyreg.cpython-35.pyc' import 'copyreg' # <_frozen_importlib_external.sourcefileloader object @ 0x108c47470> import 're' # <_frozen_importlib_external.sourcefileloader object @ 0x108bf1eb8> import '_osx_support' # <_frozen_importlib_external.sourcefileloader object @ 0x108bf1080> # /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc matches /users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/_bootlocale.py # code object '/users/fredrik/.pyenv/versions/3.5.2/lib/python3.5/__pycache__/_bootlocale.cpython-35.pyc' import '_bootlocale' # <_frozen_importlib_external.sourcefileloader object @ 0x108c47390> import 'site' # <_frozen_importlib_external.sourcefileloader object @ 0x108b17d68> python 3.5.2 (default, aug 30 2016, 00:56:52)  [gcc 4.2.1 compatible apple llvm 7.3.0 (clang-703.0.31)] on darwin type "help", "copyright", "credits" or "license" more information. # /users/fredrik/code/scikit-learn/__pycache__/sklearn.cpython-35.pyc matches /users/fredrik/code/scikit-learn/sklearn.py # code object '/users/fredrik/code/scikit-learn/__pycache__/sklearn.cpython-35.pyc' traceback (most recent call last):   file "sklearn.py", line 1, in <module>     sklearn import datasets   file "<frozen importlib._bootstrap>", line 969, in _find_and_load   file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked   file "<frozen importlib._bootstrap>", line 673, in _load_unlocked   file "<frozen importlib._bootstrap_external>", line 665, in exec_module   file "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed   file "/users/fredrik/code/scikit-learn/sklearn.py", line 1, in <module>     sklearn import datasets importerror: cannot import name 'datasets' # clear builtins._ # clear sys.path # clear sys.argv # clear sys.ps1 # clear sys.ps2 # clear sys.last_type # clear sys.last_value # clear sys.last_traceback # destroy sklearn # clear sys.path_hooks # clear sys.path_importer_cache # clear sys.meta_path # clear sys.__interactivehook__ # clear sys.flags # clear sys.float_info # restore sys.stdin # restore sys.stdout # restore sys.stderr # cleanup[2] removing encodings.latin_1 # cleanup[2] removing _locale # cleanup[2] removing __main__ # destroy __main__ # cleanup[2] removing os.path # cleanup[2] removing _sysconfigdata # destroy _sysconfigdata # cleanup[2] removing _bootlocale # destroy _bootlocale # cleanup[2] removing sysconfig # destroy sysconfig # cleanup[2] removing zipimport # cleanup[2] removing sre_compile # cleanup[2] removing _stat # cleanup[2] removing _collections_abc # destroy _collections_abc # cleanup[2] removing posixpath # cleanup[2] removing _imp # cleanup[2] removing _weakrefset # destroy _weakrefset # cleanup[2] removing marshal # cleanup[2] removing _frozen_importlib_external # cleanup[2] removing posix # cleanup[2] removing sre_constants # destroy sre_constants # cleanup[2] removing builtins # cleanup[2] removing site # destroy site # cleanup[2] removing sre_parse # cleanup[2] removing _weakref # cleanup[2] removing encodings # destroy encodings # cleanup[2] removing errno # cleanup[2] removing encodings.utf_8 # cleanup[2] removing _codecs # cleanup[2] removing os # cleanup[2] removing _frozen_importlib # cleanup[2] removing _warnings # cleanup[2] removing sys # cleanup[2] removing codecs # cleanup[2] removing abc # cleanup[2] removing _io # cleanup[2] removing stat # cleanup[2] removing encodings.aliases # cleanup[2] removing copyreg # cleanup[2] removing io # destroy io # destroy abc # cleanup[2] removing _osx_support # destroy _osx_support # cleanup[2] removing _thread # cleanup[2] removing _sre # cleanup[2] removing genericpath # cleanup[2] removing re # cleanup[2] removing _signal # cleanup[2] removing _sitebuiltins # destroy zipimport # destroy _signal # destroy _sitebuiltins # destroy posixpath # destroy errno # destroy _stat # destroy genericpath # destroy stat # destroy os # destroy re # destroy sre_compile # destroy copyreg # destroy sre_parse # destroy _sre # destroy _locale # cleanup[3] wiping encodings.latin_1 # cleanup[3] wiping _imp # cleanup[3] wiping marshal # cleanup[3] wiping _frozen_importlib_external # destroy marshal # cleanup[3] wiping posix # destroy posix # cleanup[3] wiping _weakref # cleanup[3] wiping encodings.utf_8 # cleanup[3] wiping _codecs # cleanup[3] wiping _frozen_importlib # destroy _frozen_importlib_external # destroy _weakref # destroy _imp # cleanup[3] wiping _warnings # destroy _warnings # cleanup[3] wiping codecs # cleanup[3] wiping _io # destroy io # cleanup[3] wiping encodings.aliases # cleanup[3] wiping _thread # destroy _thread # cleanup[3] wiping sys # cleanup[3] wiping builtins # destroy _frozen_importlib 

the error caused file have named /users/fredrik/code/scikit-learn/sklearn.py

the sklearn library being overridden local file, need rename sklearn.py file in project else , should work.


Comments