200 字
1 分钟
安装xgboost
这两天做模型集成需要用到xgboost,记录一下自己本机编译时Google到的小坑。
查看系统的gcc版本:
➜ gcc --versionConfigured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1Apple LLVM version 9.0.0 (clang-900.0.39.2)Target: x86_64-apple-darwin17.4.0Thread model: posixInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin此输出这说明系统路径中没有真正的gcc,有的只是Xcode指向Clang的连接。 (参考:how to find gcc version on mac)
列出macports中安装的gcc:
➜ port select --list gccAvailable versions for gcc: mp-gcc5 mp-gcc6 none (active)按照官方帮助,路径在/opt/local/bin/下找到名为gcc-mp-5及g++-mp-5的程序,运行:
➜ export CC=/opt/local/bin/gcc-mp-5export CXX=/opt/local/bin/g++-mp-5pip install xgboost(参考:How to use the gcc installed in macports?)
在环境中运行import xgboost as xgb测试通过。
如果确实需要修改系统中gcc指向的编译器,可以使用sudo port select --set gcc mp-gcc5
(参考:http://www.ficksworkshop.com/blog/post/installing-gcc-on-mac)