Alex Stanovsky
Alex Stanovsky

Reputation: 1366

xgboost on Sagemaker notebook import fails

I am trying to use XGBoost on Sagemaker notebook.

I am using conda_python3 kernel, and the following packages are installed:

But once I am trying to import xgboost it fails on import:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-5943d1bfe3f1> in <module>()
----> 1 import xgboost as xgb

ModuleNotFoundError: No module named 'xgboost'

Upvotes: 0

Views: 2490

Answers (1)

Anshuman Ranjan
Anshuman Ranjan

Reputation: 180

In Sagemaker notebooks use the below steps

a) If in Notebook

i) !type python3

ii) Say the above is /home/ec2-user/anaconda3/envs/python3/bin/python3 for you

iii) !/home/ec2-user/anaconda3/envs/python3/bin/python3 -m pip install xgboost

iv) import xgboost


b) If using Terminal

i) conda activate conda_python3
ii) pip install xgboost

Disclaimer : sometimes the installation would fail with gcc version ,in that case update pip version before running install

Upvotes: 3

Related Questions