基於linux6.x安裝xgboost
基於linux6.x安裝xgboost
系統信息
[root@ceshiji ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
python信息
[root@ceshiji ~]# python --version
Python 2.7.3
安裝基礎插件(安裝 anaconda)
[root@ceshiji ~]# yum install gcc gcc-c++
[root@ceshiji ~]# yum install lapack lapack-devel blas blas-devel
[root@ceshiji ~]# yum install scipy numpy
安裝pip
說明:關於pip的安裝,請參考博文:http://wutengfei.blog.51cto.com/10942117/1975003
安裝安裝sk-learn
[root@ceshiji ~]# pip install -U scikit-learn==0.16.0
下載xgboost 的源碼,解壓
[root@ceshiji ~]# wget https://github.com/dmlc/xgboost/archive/0.47.tar.gz
[root@ceshiji ~]# tar -zxvf 0.47.tar.gz
[root@ceshiji ~]# cd xgboost-0.47/
編譯
[root@ceshiji xgboost-0.47]# make -j4
安裝Python模塊,使用anaconda的Python
[root@ceshiji xgboost-0.47]# cd python-package/
[root@ceshiji python-package]# python setup.py install
這時系統會有報錯,如下:
解決方法:
[root@ceshiji python-package]# vim setup.py
修改setup.py中
include_package_data=False, (原來是True)
再次運行python setup.py install 即可!
提示如下表示安裝成功:
Using /root/anaconda2/lib/python2.7/site-packages
Finished processing dependencies for xgboost==0.4將xgboost導入python中
[root@ceshiji ~]# python
>>> import xgboost
>>>
說明:上面標明xgboost已經成功導入python中,我在root賬戶下操作一切正常,但我切換到普通賬戶時出現報錯,如下:
解決方法:
[root@ceshiji ~]# cd xgboost-0.47/python-package/xgboost
[root@ceshiji xgboost]# cp __init__.py /usr/local/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/
[root@ceshiji xgboost]# cp VERSION /usr/local/lib/python2.7/site-packages/xgboost-0.4-py2.7.egg/xgboost/
再次import xgboost即可!
本文出自 “聖騎士控魔之手” 博客,請務必保留此出處http://wutengfei.blog.51cto.com/10942117/1979471
基於linux6.x安裝xgboost