我正在尝试使用以下页面中的示例学习scikit:
我的机器上安装了Python2.7和3.2(Ubuntu 12.04)。当我在2.7中尝试以下行时,
from sklearn.neighbors import KernelDensity
我收到以下错误:
Python 2.7.3 (default, Feb 27 2014, 20:00:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.neighbors import KernelDensity
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name KernelDensity
当我在3.2中运行它时,我收到以下错误:
Python 3.2.3 (default, Feb 27 2014, 21:33:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.neighbors import KernelDensity
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/sklearn/neighbors/__init__.py", line 6, in <module>
from .ball_tree import BallTree
File "numpy.pxd", line 155, in init sklearn.neighbors.ball_tree (sklearn/neighbors/ball_tree.c:34290)
ValueError: numpy.dtype has the wrong size, try recompiling
我的版本是:
>>> import sklearn
>>> sklearn.__version__
'0.15-git'
我还运行了以下内容:
sudo -E pip install -U scikit-learn
然后它返回:
Requirement already up-to-date: scikit-learn in /usr/local/lib/python3.2/dist-packages
Cleaning up...
我最近一直在学习python,随着我在理解语言方面取得进步,我开始学习`sklearn'但是由于这个错误,我被困住了。我该如何解决?
在尝试不同的选项时,我还升级了numpy(到版本1.8.1),并在卸载并重新安装scikit-learn之后使用pip建议,我收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/sklearn/__init__.py", line 38, in <module>
from .base import clone
File "/usr/local/lib/python3.2/dist-packages/sklearn/base.py", line 10, in <module>
from scipy import sparse
File "/usr/lib/python3/dist-packages/scipy/__init__.py", line 124, in <module>
pkgload(verbose=SCIPY_IMPORT_VERBOSE,postpone=True)
File "/usr/local/lib/python3.2/dist-packages/numpy/_import_tools.py", line 177, in __call__
for package_name in self._get_sorted_names():
File "/usr/local/lib/python3.2/dist-packages/numpy/_import_tools.py", line 114, in _get_sorted_names
for name in depend_dict.keys():
RuntimeError: dictionary changed size during iteration