Jupyter notebook xgboost import

Viewed 31972

I have the problem below (I'm on a MAC)

I can import xgboost from python2.7 or python3.6 with my Terminal but the thing is that I can not import it on my Jupyter notebook.

import xgboost as xgb

ModuleNotFoundError Traceback (most recent call last) in () ----> 1 import xgboost as xgb

ModuleNotFoundError: No module named 'xgboost'

Although I write :

!pip3 install xgboost

It prints that :

Requirement already satisfied: xgboost in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/xgboost-0.6-py3.6.egg Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from xgboost) Requirement already satisfied: scipy in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from xgboost)

Help please I searched everywhere :(

4 Answers

Within Jupyter Notebook cell, try running:

import sys !{sys.executable} -m pip install xgboost

This allows the package to be install with right on Jupiter notebook

if you are using anaconda, you can install XGBoost with a command that mentioned below :

conda install -c conda-forge xgboost

Since you are using macOS, you can use Homebrew to install xgboost:

In your terminal, run the following command:

brew install xgboost

See this for details.

Related