conda update scikit-learn(也是scipy和numpy)

Blu*_*482 3 numpy scipy python-2.7 scikit-learn anaconda

当我应该使用conda时,我想我使用pip install弄得一团糟.因此,我无法将scikit-learn软件包更新到最新版本.我用conda和pip卸载scikit-learn,然后使用conda重新安装但是现在我有问题导入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 "<stdin>", line 1, in <module>
  File "/Users/bowang/anaconda/lib/python2.7/site-packages/sklearn/metrics/__init__.py", line 7, in <module>
    from .ranking import auc
ImportError: No module named ranking 
Run Code Online (Sandbox Code Playgroud)

此外,它实际上使用的sklearn/numpy/scipy版本似乎存在混淆:

$ conda update scikit-learn
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: .........

# All requested packages already installed.
# packages in environment at /Users/bowang/anaconda:
#
scikit-learn              0.15.2               np18py27_0    http://repo.continuum.io/pkgs/free/osx-64/scikit-learn-0.15.2-np18py27_0.tar.bz2

$ conda update scipy
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: .........

# All requested packages already installed.
# packages in environment at /Users/bowang/anaconda:
#
scipy                     0.14.0               np18py27_0    http://repo.continuum.io/pkgs/free/osx-64/scipy-0.14.0-np18py27_0.tar.bz2
Run Code Online (Sandbox Code Playgroud)

以上显示我仍然无法更新到最新版本但是:

$ python
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
>>> import scipy
>>> scipy.__version__
'0.17.0'
>>> import numpy
>>> numpy.__version__
'1.11.0'
>>> import sklearn
>>> sklearn.__version__
'0.17.1'
Run Code Online (Sandbox Code Playgroud)

有没有办法清理和解决这里的所有混淆,并允许我更新,从而使用最新版本的sklearn/numpy/scipy?谢谢!

jak*_*vdp 6

看起来conda报告的版本与运行Python时导入的版本不匹配.这让我觉得你已经在多个地方安装了这些软件包,并$PYTHONPATH设置了你的变量,以便Python找到不同的安装(有时安装一些工具包会在你的bash/sh启动脚本中添加它)尝试运行

$ echo $PYTHONPATH
Run Code Online (Sandbox Code Playgroud)

如果此处显示任何内容,请找到您的启动脚本并对其进行评论.确保$PYTHONPATH为空后,请尝试以下操作:

$ conda update conda  # make sure package listing is up-to-date
$ conda remove numpy scipy scikit-learn
$ conda install scikit-learn
Run Code Online (Sandbox Code Playgroud)

这在过去对我来说一般都有用.