1.概述
在没有安装XGBoost之前,import xgboot会出错,如下:
# ModuleNotFoundError: No module named ‘xgboost’
2.安装xgboost
前提条件:
windows环境下,anaconda(这里指的是Anaconda3)已安装,相应的numpy和sicpy已安装
下面介绍最简单的安装方式:
打开Anaconda Prompt
输入命令 :
# pip install xgboost -i https://pypi.tuna.tsinghua.edu.cn/simple
“-i https://pypi.tuna.tsinghua.edu.cn/simple” 这是清华镜像,包从这里下载,速度比较快;否则,默认国外的镜像,下载速度慢,可能会安装失败。
效果如下:
到这里无论是系统的python或者还是jupyter都可以使用xgboost包了。

在没有安装XGBoost时,尝试导入会报错。解决方法是在Anaconda Prompt中使用`pip install xgboost -i https://pypi.tuna.tsinghua.edu.cn/simple`命令,利用清华镜像加速下载,确保numpy和scipy已预先安装。完成安装后,xgboost即可在Python或Jupyter中正常使用。
832





