简体   繁体   中英

Installing XGBoost

I am trying use the XGBoost package, but I am having trouble installing it. I am following the installation guide here https://xgboost.readthedocs.io/en/latest/build.html#python-package-installation . I have successfully built xgboost for OSX using

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/minimum.mk ./config.mk; make -j4

However, when I try to install the python package in my terminal using this code

cd python-package; sudo python setup.py install

I get the error python: command not found . I am not sure why I get this error because I have python installed and I can run ipython notebooks. Python is install here on my computer /usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7 . Do I need to add a path in my bash_profile to access it? I don't understand why I can't use python from the command line.

I have answered similar issue in this question . You can install xgboost library along with other essential libraries as follows(please choose based on the libraries sufficient for your project), my main focus in this answer is to make it helpful in setting up for most data science projects requiring sklearn, pandas, scipy and xgboost algorithms along with visualization libraries.

# installing essentials
apt-get update; \
apt-get install -y \
  python python-pip \
  build-essential \
  python-dev \
  python-setuptools \
  python-matplotlib \
  libatlas-dev \
  curl \
  libatlas3gf-base && \
  apt-get clean

# upgrading pip
curl -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py
# installing libraries
pip install numpy==1.13.1
pip install scipy
pip install -U scikit-learn
pip install seaborn
pip install --pre xgboost

If you're still having environment issues I would suggest using this Dockerfile . You might also find Datmo conversion useful to facilitate this.

DISCLAIMER: I work at this company called Datmo , which is building a community of developers by simplifying the machine learning workflow.

If you have python in your /usr/bin/ directory, all you need to do is to add that directory to your path.

Add this line to your .bash_profile and restart your shell.

export PATH="$PATH:/usr/bin"

Then you should be able to use any of the python versions in your /usr/bin directory. python , python3 etc. Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM