Sagemaker笔记本电脑上的xgboost导入失败

时间:2020-06-10 21:37:23

标签: python jupyter-notebook conda xgboost amazon-sagemaker

我正在尝试在Sagemaker笔记本电脑上使用XGBoost。

我正在使用conda_python3内核,并安装了以下软件包:

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

但是一旦我尝试导入xgboost,导入就会失败:

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

ModuleNotFoundError: No module named 'xgboost'

2 个答案:

答案 0 :(得分:2)

在Sagemaker笔记本中,请执行以下步骤

a)如果在笔记本电脑中

i)!type python3

ii)说上面的是/ home / ec2-user / anaconda3 / envs / python3 / bin / python3为您提供

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

iv)import xgboost


b)如果使用终端机

i)conda activate conda_python3
ii)pip install xgboost

免责声明:有时安装会因gcc版本而失败,在这种情况下,请在运行install之前更新pip版本

答案 1 :(得分:-1)

尝试重新安装

pip uninstall xgboost
pip install xgboost