Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are ImportErrors? #5146

Closed
laghaout opened this issue Aug 21, 2015 · 2 comments
Closed

What are ImportErrors? #5146

laghaout opened this issue Aug 21, 2015 · 2 comments

Comments

@laghaout
Copy link

Hi,

I installed scikit-learn from Anaconda without any apparent errors since I get a confirmation that the package is up to date:

C:\Users\Anaconda3>conda update scikit-learn
Fetching package metadata: ....
\# All requested packages already installed.
\# packages in environment at C:\Users\Anaconda3:
\#
scikit-learn    0.16.1  np19py34_0

However, whenever I actually try to use it, I get the recurring error message:

ERROR: Failure: ImportError (cannot import name 'doccer')

I ran nosetests to check the installation of sklearn and the same error about this 'doccer' thing comes up. Just what are these import errors and how can I fix them? I have uninstalled and re-installed scikit many times, both with pip and conda, but to no avail.

My specs are as follows:

  • Python 3.4.1
  • Anaconda 2.1.0
  • Computer: Windows 7 (32-bit)
  • IDE: Spyder 2.3.1
@lesteve
Copy link
Member

lesteve commented Aug 21, 2015

ERROR: Failure: ImportError (cannot import name 'doccer')

Next time, could you give the full stacktrace? This may seem like complete rubbish to you but it is actually very useful to understand where the error comes from.

Googling around doccer seems to be a scipy thing (scipy.misc.doccer, see this for example), so it looks like something went wrong during your scipy install.

The simplest thing to do is to uninstall and reinstall numpy, scipy and scikit-learn. Because you mixed pip and conda, which is probably not a good idea (I only use pip for the packages that are not available through conda), I would recommend to pip uninstall them first just in case:

pip uninstall numpy scipy -y
pip uninstall scikit-learn -y

then conda uninstall them

conda uninstall numpy scipy scikit-learn -y

then reinstall them again

conda install numpy scipy scikit-learn -y

Once this is done, python -c 'import sklearn' should succeed without errors.

@willettk
Copy link

willettk commented Dec 1, 2015

Finally! Very useful - thank you, @laghaout. Just posting the trace that I had (that the conda install fixed) in case it's helpful for anyone else Googling the same error messages.

In [1]: from sklearn.cluster import dbscan
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-1fa0b05b17e1> in <module>()
----> 1 from sklearn.cluster import dbscan

//anaconda/lib/python2.7/site-packages/sklearn/cluster/__init__.py in <module>()
      4 """
      5 
----> 6 from .spectral import spectral_clustering, SpectralClustering
      7 from .mean_shift_ import (mean_shift, MeanShift,
      8                           estimate_bandwidth, get_bin_seeds)

//anaconda/lib/python2.7/site-packages/sklearn/cluster/spectral.py in <module>()
     14 from ..utils.validation import check_array
     15 from ..utils.extmath import norm
---> 16 from ..metrics.pairwise import pairwise_kernels
     17 from ..neighbors import kneighbors_graph
     18 from ..manifold import spectral_embedding

//anaconda/lib/python2.7/site-packages/sklearn/metrics/__init__.py in <module>()
      5 
      6 
----> 7 from .ranking import auc
      8 from .ranking import average_precision_score
      9 from .ranking import coverage_error

//anaconda/lib/python2.7/site-packages/sklearn/metrics/ranking.py in <module>()
     31 from ..utils.fixes import array_equal
     32 from ..utils.stats import rankdata
---> 33 from ..utils.sparsefuncs import count_nonzero
     34 
     35 from .base import _average_binary_score

ImportError: cannot import name count_nonzero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants