xgboost on Sagemaker notebook import fails

◇◆丶佛笑我妖孽 提交于 2021-02-07 11:13:24

问题


I am trying to use XGBoost on Sagemaker notebook.

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

  • py-xgboost-mutex
  • libxgboost
  • py-xgboost
  • py-xgboost-gpu

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'

回答1:


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




回答2:


try reinstalling

pip uninstall xgboost
pip install xgboost


来源:https://stackoverflow.com/questions/62313532/xgboost-on-sagemaker-notebook-import-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!