我得到的错误如下:
$ python -c 'from sklearn import preprocessing'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/scikit_learn-0.10-py2.6-linux-x86_64.egg/sklearn/preprocessing/__init__.py", line 17, in <module>
from ..utils.sparsefuncs import inplace_csr_row_normalize_l1
File "numpy.pxd", line 174, in init sklearn.utils.sparsefuncs (sklearn/utils/sparsefuncs.c:4605)
ValueError: numpy.ndarray has the wrong size, try recompiling
我认为这是 numpy 而不是 scikitlearn 的错误(参见 here )
我使用的是 scipy 和 numpy 的开发版本,通过 git clone 安装(并且工作正常)。但是我需要“降级”到稳定版本才能发布。所以我删除了 git 文件夹,并从 /usr/local/lib/python-2.6/ 中删除了 egg 文件。 (为了安全起见)然后我做了:
$ sudo apt-get install libblas-dev liblapack-dev
$ sudo apt-get install python-dev python-numpy python-scipy
$ sudo easy_install -U distribute
$ sudo easy_install -U numpy
$ sudo easy_install -U scipy
最后两个都给了我警告......
RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
...我不确定这是不是出了什么问题?
$ python -c 'import numpy; print numpy.__version__'
1.6.2
$ python -c 'import scipy; print scipy.__version__'
0.10.1
我已经尝试删除已安装的 apt 版本,但这似乎无济于事。这是带有 2.6.32-21-server 内核
请您参考如下方法:
我建议安装 Enthought Python Distribution。它是免费的,安装在 Ubuntu 10.04 上,并随 Numpy、Scipy、matplotlib 等一起提供。
