Sage 7.2 中的 Scikit-learn 和 pandas

Scikit-learn and pandas in Sage 7.2

我正在尝试将 scikit-learn 和 pandas 放入 Sage 7.2(在 El Capitan 上)。我已经在 Sage 6.6 中成功地做到了这一点。但是,当我输入 /Applications/SageMath-7.2.app/Contents/Resources/sage/sage --pip install scikit-learnpandas 的结果相同)时,我收到以下错误消息。

creating build/temp.macosx-10.9-x86_64-2.7
creating build/temp.macosx-10.9-x86_64-2.7/sklearn
creating build/temp.macosx-10.9-x86_64-2.7/sklearn/svm
creating build/temp.macosx-10.9-x86_64-2.7/sklearn/svm/src
creating build/temp.macosx-10.9-x86_64-2.7/sklearn/svm/src/libsvm
compile options: '-I/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.9-x86_64.egg/numpy/core/include -c'
g++: sklearn/svm/src/libsvm/libsvm_template.cpp
In file included from sklearn/svm/src/libsvm/svm.cpp:53:0,
                 from sklearn/svm/src/libsvm/libsvm_template.cpp:6:
/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/gcc/x86_64-apple-darwin15.4.0/4.9.3/include-fixed/math.h:45:23: fatal error: sys/cdefs.h: No such file or directory
 #include <sys/cdefs.h>
                       ^
compilation terminated.
In file included from sklearn/svm/src/libsvm/svm.cpp:53:0,
                 from sklearn/svm/src/libsvm/libsvm_template.cpp:6:
/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/gcc/x86_64-apple-darwin15.4.0/4.9.3/include-fixed/math.h:45:23: fatal error: sys/cdefs.h: No such file or directory
 #include <sys/cdefs.h>
                       ^
compilation terminated.
error: Command "g++ -fno-strict-aliasing -I/Applications/SageMath-7.2.app/Contents/Resources/sage/local/var/tmp/sage/build/python2-2.7.10.p1/include -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -I/Applications/SageMath-7.2.app/Contents/Resources/sage/local/lib/python2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.9-x86_64.egg/numpy/core/include -c sklearn/svm/src/libsvm/libsvm_template.cpp -o build/temp.macosx-10.9-x86_64-2.7/sklearn/svm/src/libsvm/libsvm_template.o" failed with exit status 1

----------------------------------------
Command failed with error code 1

我一直找不到任何继续进行的方法。我能想到的唯一问题是安装说明参考 macosx-10.9,但 El Capitan 是 10.11。所以也许这就是问题所在?

您的问题是注释 No such file or directory。我建议你安装命令行工具,甚至 Xcode。你是按照以下顺序做的吗?

  1. 安装 Sage
  2. 在某个时候,升级您的 Mac OS
  3. 升级你的贤者
  4. 尝试安装pandas等

如果是这样,可能就是问题所在。我刚刚升级了我的 Mac 并且不得不重新安装命令行工具两次才能识别它。幸运的是,现在这不是很难 - 打开终端并尝试使用 gcc 或其他东西,它 应该 提示你,尽管你的里程可能会有所不同。

那么你的命令应该可以正常工作,它对我有用。