当我尝试通过以下方式在 Suse (openSuse 12.2 x86_64) 服务器上安装 scikit-learn 时:
pip install -U scikit-learn
我收到以下错误:
(....)
compile options: '-I/usr/lib64/python2.7/site-packages/numpy/core/include -Isklearn/svm/src/libsvm -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c'
gcc: sklearn/svm/libsvm.c
sklearn/svm/libsvm.c:303:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
sklearn/svm/libsvm.c:303:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
我已经试过了:
-安装gcc到最新版本
- 通过 easy_install 从下载的 zip 安装 scikit(以避免旧的 repos)
- 卸载并重新安装 numpy(通过 pip)
当我尝试安装 scipy(这是 numpy 的要求)时,我得到了类似的错误:
adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources.
adding 'build/src.linux-x86_64-2.7' to include_dirs.
error: file '/usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c' does not exist
显然“site-packages/numpy/core/include”中的所有 numpy header 都丢失了。我已经用 pip 重新安装了 numpy,没有任何问题,但标题仍然丢失。
最佳答案
好的,当我用 pip 安装 numpy 时,或者通常所有包含 header 都丢失了。
为了解决这个问题,我安装了包含 header 的包“python-numpy-devel”(带有 zypper、愚蠢的 suse 包名称...)。
在那之后,标题就在那里,其余的工作。
关于python - scikit-learn 安装失败/找不到 numpy/缺少 numpy header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18334472/