I just installed sklearn using pip. When I try to import anything I get an AttributeError.
import sklearn # No error
from sklearn import svm # AttributeError
from sklearn import datasets # Same AttributeError
Full output: Traceback (most recent call last): test.py", line 1, in
from sklearn import cluster File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\cluster__init__.py", line 6, in
from .spectral import spectral_clustering, SpectralClustering File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\cluster\spectral.py", line 15, in
from ..metrics.pairwise import pairwise_kernels File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\metrics__init__.py", line 7, in
from .ranking import auc File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn\metrics\ranking.py", line 27, in
from scipy.stats import rankdata File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\stats__init__.py", line 345, in
from .stats import * File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\stats\stats.py", line 171, in
from . import distributions File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\stats\distributions.py", line 13, in
from . import _continuous_distns File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\stats_continuous_distns.py", line 113, in
class norm_gen(rv_continuous): File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\stats_continuous_distns.py", line 175, in norm_genoptimizerargument is ignored.\n\n""") File "AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\misc\doccer.py", line 159, in _doc start_of_notes = cls_docstring.find(notes_header) AttributeError: 'NoneType' object has no attribute 'find'
# From doccer.py
def _doc(func):
cls_docstring = getattr(cls, func.__name__).__doc__
notes_header = ' Notes\n -----\n'
# XXX The following assumes that there is a Notes section.
start_of_notes = cls_docstring.find(notes_header) # This is line 159
end_of_notes = cls_docstring.find(' References\n')
if end_of_notes == -1:
end_of_notes = cls_docstring.find(' Examples\n')
if end_of_notes == -1:
end_of_notes = len(cls_docstring)
func.__doc__ = (cls_docstring[:start_of_notes + len(notes_header)] +
notes +
cls_docstring[end_of_notes:])
return func
return _doc
I'm using Python 3.7.1
Does anyone have an idea how this problem can be fixed?
I'm not sure what more information to include, so if you need more information please tell me to do so.
EDIT1:
I tried doing the exact same thing on my pc, and it works just fine. This problem only occurs when using my laptop.
-OOon? If so, try turning off-OO. - user2357112 supports Monica-OOis a command-line option. Depending on how you're running Python, you may need to check IDE options or something similar to see what the command line options look like. - user2357112 supports Monicaimport sklearnand thesklearn.__version__. What is the output ? - seralouk