我想我在使用pip install时搞砸了,因为我应该使用conda。结果我无法将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
同时也存在混淆,不知道它实际使用的是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
上文显示我仍无法更新到最新版本,但是:
$ 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'
有没有一种方法可以清理并解决所有混乱,让我更新并使用最新版本的sklearn / numpy / scipy?谢谢!
$PYTHONPATH
已经为空了,所以我使用conda卸载并安装了scikit-learn,现在我有了最新版本。只是再次确认一下,从现在开始,我将需要使用conda install
来安装每个第三方Python包吗?还是我也可以使用pip install
? - Blue482pip install --user --install-option="--prefix=" -U scikit-learn
,有关安装和升级的帮助,请参阅http://scikit-learn.org/stable/developers/advanced_installation.html。 - Ruthger Righartscipy
(以及两个numpy
),一个在 conda 中,另一个在/usr/local/lib/python3.5/dist-packages/
中。使用pip3 uninstall scipy
从/usr/local/lib
卸载了这两个模块,然后 anaconda 又开始使用自己的安装,可以通过conda update
进行更新。 - Aleksander Lidtke