No module named ERROR: conda update scikit-learn (also scipy and numpy)

系统:win7 x64
Anaconda: 3.19.0
Python: 2.7.9
  • 错误:

导入numpy、scipy、theano等模块统统报错No module named version。
尝试修改系统环境变量,如添加d:\Anaconda;d:\Anaconda\Lib;C:\Python27;C:\Python27\Lib等,然并卵。在网上也没找到什么解决方法。

  • 错误原因:

回头查看错误提示,发现都是numpy中的init部分中的from version import git_revision as git_revision代码报错,应该是numpy模块版本的原因,具体是版本怎么出错了,太低还是太高,不知道。
解决方法:

numpy出问题,就重装或者更新numpy模块。
由于我使用的是Anaconda,所以在Anaconda Command Prompt中输入conda update numpy,等待numpy及其相关依赖安装完成即可,问题不再出现


I think I have made a mess using pip install when I am supposed to use conda. As a result I couldn’t update the scikit-learn package to the latest version. I uninstalled scikit-learn with both conda and pip, and then installed again using conda but now I have issue import sklearn:

Python 2.7.11 |Anaconda custom (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

from sklearn import metrics
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/bowang/anaconda/lib/python2.7/site-packages/sklearn/metrics/__init__.py", line 7, in 
    from .ranking import auc
ImportError: No module named ranking 

It looks like the versions reported by conda do not match the versions you’re importing when you run Python. This makes me think that you’ve installed these packages in multiple places, and have your $PYTHONPATH variable set so that Python is finding different installations (sometimes installing some toolkit will add this in your bash/sh startup script) Try running

$ echo $PYTHONPATH
If anything is shown here, find your startup script and comment that out. After making sure that $PYTHONPATH is empty, try the following:

$ conda update conda  # make sure package listing is up-to-date
$ conda remove numpy scipy scikit-learn
$ conda install scikit-learn

That has generally worked for me in the past.


you could try using Anaconda to create a virtual environment and then install sklearn via conda rather than pip

https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/ http://conda.pydata.org/docs/using/pkgs.html#install-a-package

conda create -n yourenvname python=3.5 anaconda
conda install -n yourenvname sklearn

你可能感兴趣的:(====python====)