Search code examples
pandasscikit-learnpiposx-elcapitansage

Scikit-learn and pandas in Sage 7.2


I'm trying to put scikit-learn and pandas into Sage 7.2 (on El Capitan). I'd successfully done this in Sage 6.6. However, when I enter /Applications/SageMath-7.2.app/Contents/Resources/sage/sage --pip install scikit-learn (same result for pandas), I get the following error message.

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

I've been unable to find any way to proceed. The only problem I can think of is that the install instructions refer to macosx-10.9, but El Capitan is 10.11. So maybe that's the problem?


Solution

  • Your problem is the note No such file or directory. I suggest you install the command line tools, or even Xcode. Did you do things in the following order?

    1. Install Sage
    2. At some point, upgrade your Mac OS
    3. Upgrade your Sage
    4. Try to install pandas etc.

    If so, probably this is the problem. I just upgraded my Mac and had to reinstall command line tools twice before it would recognize it. Luckily, this isn't very hard nowadays - open a Terminal and try to use gcc or something and it should prompt you, though your mileage may vary.

    Then your command should work fine, it works for me.